【发布时间】:2017-10-09 18:27:48
【问题描述】:
到目前为止,我已经使用以下内容解析出一段 xml,如下所示:
<report>
<otherSections>
</otherSections>
...
<inquiries>
<inquiry>
<date>01/01/06</date>
</inquiry>
..more inquiries
</inquiries>
..more sections
</report>
<cfset numInquiries = ArrayLen(Report.inquiries.XmlChildren) >
<cfloop index="i" from = "1" to = "#numInquiries#" >
<cfset strInquiryID = Report.inquiries.inquiry[i].date.XMLText/>
</cfloop>
我没有意识到有时xml是这样的:
<report>
<otherSections>
</otherSections>
...
<inquiries>
<inquiry>
<date>02/01/06</date>
</inquiry>
..more inquiries
</inquiries>
<inquiries>
<inquiry>
<date>01/01/06</date>
</inquiry>
..more inquiries
</inquiries>
..more sections
</report>
我不知道报告中还有多少其他孩子或有多少查询标签,但我只想解析查询及其孩子。我怎样才能用coldfusion解析这个?
【问题讨论】:
-
您到底遇到了什么问题?
report有 n 个孩子可以循环:Report.XmlChildren -
对,但我只想循环遍历称为查询的孩子。
标签: xml coldfusion