在ColdFusion中解析文件夹中的日志文件 [英] Parsing log files in a folder in ColdFusion

查看:190
本文介绍了在ColdFusion中解析文件夹中的日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是有一个文件夹 ./ log / 包含如下文件:

The problem is there is a folder ./log/ containing the files like:

jan2010.xml, feb2010.xml, mar2010.xml, jan2009.xml, feb2009.xml, mar2009.xml ...

每个xml文件将:

<root><record name="bob" spend="20"></record>...(more records)</root>



我想写一个ColdFusion代码( log.cfm ),只是解析这些xml文件。对于前端我会让用户选择一年,然后点击提交按钮。该年度的所有内容将按月份显示在单独的表格中。每个表格显示每个人的总花费。例如:

I want to write a piece of ColdFusion code (log.cfm) that simply parsing those xml files. For the front end I would let user to choose a year, then the click submit button. All the content in that year will be show up in separate table by month. Each table shows the total money spent for each person. like:

person   cost
bob      200
mike     300
Total    500

谢谢。

推荐答案

简单的答案是,如果你的XML格式正确,可以使用XMLParse()函数将XML转换成CF数据对象。

The short answer is that, if your XML is correctly formatted, you can use the XMLParse() function to get the XML into a CF data object.

Sergii指向XMLParse cna需要一个路径,所以你可以直接读取文件并将结果分配给一个变量。

Sergii pointed out that XMLParse cna take a path, so you can simply read the file directly into it and assign the results to a variable.

数据应该看起来像一个数组结构。在CF数据对象上使用CFDUMP查看它,并帮助您计算出来。

The data should look something like an array of structures. Use CFDUMP on your CF data object to view it and help you figure it out.

这篇关于在ColdFusion中解析文件夹中的日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆