Reputation: 1848
Given the following XML "thisXML":
I can obtain the product name via
<cfset vProduct = thisXML.xmlchildren[1].xmltext>
But, how do obtain a value by xmlName, rather than by xmlChildren array position, i.e. in pseudocode:
<cfset vProduct = thisXML.xmlchildren[xmlName='product'].xmltext>
Upvotes: 0
Views: 1035
Reputation: 8123
You should be able to get to it with thisXML.Product
- it worked for me.
--xmltest.xml
<table1>
<product>KiaOra</product>
<SubscriberCode>2232481600</SubscriberCode>
</table1>
--xmltest.cfm
<cfscript>
// this is setup stuff
f = FileRead(expandPath("xmltest.xml"));
x = XmlParse(f);
xDetail = XmlSearch(x,"/table1")[1]; // this gets the exact result your cfdump image has
// here is the important part
writeOutput(xDetail.product.xmlText);
</cfscript>
--output
KiaOra
You just have to realize that even though your XML prints out in the detail view, it still works like XML in the standard cfdump view.
Upvotes: 3