Skip to main content
Participating Frequently
July 15, 2008
Answered

XML Parsing

  • July 15, 2008
  • 3 replies
  • 745 views
I am having no luck in Coldfusion in getting to the values of PID and ID in the following returned XML file. Any suggestions?

<cfxml variable="test">

<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

<ProjectDataset xmlns=" http://tempuri.org/ProjectDataset.xsd">
<Project diffgr:id="Project1" msdata:rowOrder="0">
<PID>1234</PID>
<ID>1234</ID>
</Project>
</ProjectDataset>
</diffgr:diffgram>

</cfxml>

Thanks in advance...
This topic has been closed for replies.
Correct answer Newsgroup_User
<cfoutput>
#test['diffgr:diffgram']['ProjectDataset']['Project']['PID']['XMLText']#
#test['diffgr:diffgram']['ProjectDataset']['Project']['ID']['XMLText']#
</cfoutput>

<cfdump var="#test#" format="html">

This should get you started.

3 replies

Inspiring
July 15, 2008
Stressed_Simon wrote:
> ...
> <cfset xTest = xmlParse(trim(test))>

I'll point out that xmlParse() is unnecessary here, since the <cfxml...>
tag already creates an xml object in ColdFusion.

It would be use if one was converting an XML string into an xml object.
Inspiring
July 15, 2008
Good point. Only half read it!
Inspiring
July 15, 2008
Easy:-
Newsgroup_UserCorrect answer
Inspiring
July 15, 2008
<cfoutput>
#test['diffgr:diffgram']['ProjectDataset']['Project']['PID']['XMLText']#
#test['diffgr:diffgram']['ProjectDataset']['Project']['ID']['XMLText']#
</cfoutput>

<cfdump var="#test#" format="html">

This should get you started.
ctlcalAuthor
Participating Frequently
July 15, 2008
Thanks - that is exactly what I needed.