I’m still a bit of an xml idiot. Sometimes I get it and sometimes not.
I have the following XML which derives ultimately from a parsed .NET webservice output. I’ve wrapped it in a cfxml tag for the purposes of this question, but in reality I’m parsing an xml document.
<cfxml variable="local.vXML">
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<ResponseCode>3</ResponseCode>
<ResponseText>Incorrect PIN. Please try again</ResponseText>
</Table>
</NewDataSet>
</diffgr:diffgram>
</cfxml>
I want to get at the <ResponseCode> and <ResponseText> nodes.
How would I do that?
Various efforts, such as the following
<cfset Local.xSet = xmlSearch(local.vXML,"NewDataSet") />
<cfset Local.xSet = xmlSearch(local.vXML,"Table") />
<cfset Local.xSet = xmlSearch(local.vXML,"ResponseCode") />
yield an empty array
THE SOLUTION
Thanks for Jake for his CF9 solution. Adapted below for CF8.
<cfset vResponseCodeXML = XMLSearch(Local.vXML, '//Table[@diffgr:id="Table1"]/ResponseCode')>
<cfset vResponseTextXML = XMLSearch(Local.vXML, '//Table[@diffgr:id="Table1"]/ResponseText')>
<cfset vResponseCode = vResponseCodeXML[1].XmlText>
<cfset vResponseText = vResponseTextXML[1].XmlText>
Try this: