Question
Which is the best way to parse nested XML
Hello, I am just getting back into using ColdFusion and I am working on a project that needs to parse some XML.
The XML is generated by a third party document.
I figured out how to grab individual values and such, but I'm not sure what is the best way to grab a value in relation to where it is in the XML.
Following is a rather simplified example of the XML
I need to grab the value of 'Rich Text' in relation to the 'ID name' value.
<project>
<CT text>
<Group>
<id name = text1>
<Rich Text>some sample text</Rich Text>
</id>
</Group>
</CT Text>
<CT text>
<Group>
<Group>
<id name = text1>
<Rich Text>some sample text</Rich Text>
</id>
</Group>
</Group>
</CT Text>
<CT text>
<id name = text2>
<Rich Text>some more sample text</Rich Text>
</id>
</CT Text>
</project>
Once parsed, the info I need to output on the page would look like
text 1
some sample text
text 2
some more sample text
The part that makes this difficult for me is that there may be 0 'Group' values or there might be a number of them. As such, I can't just grab the value by listing the tree out, since it changes depending on the document (there are thousands of these documents that I need to parse).
From what I have seen in some XML examples, there are a number of ways to go about doing this, but before I put a lot of time into any of them, I was wondering what the 'best' way to do this is.
XSLT? XMLSearch? Structures? Some combination of those or other functions?
P.S. what little I know of using ColdFusion with XML all comes from the doc written by Nate Weiss.
I was a bit let down that after spending well over $1,000 for ColdFusion, Adobe left out the only two books that were worth printing (the CFML reference guide and the Advanced book). It wouldn't have bothered me as much if there was something on the product page listing the manuals that said 'we only actually give you 2 of the ones listed'.
Best regards
Kevin R.