Skip to main content
September 27, 2008
Question

xml post Urgent

  • September 27, 2008
  • 3 replies
  • 864 views
Hi can someone please help me, i need to read a xml post but not sure how to do it..

the xml post comes to my url in this format

<DeliveryReport><message id="1023012301" sentdate=""
donedate="2005/7/19 22:0:0" status="NOT_SENT" /></DeliveryReport>

all i need to get is the message id and the status

thanks
This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
September 28, 2008
so how do i go down the children to get the value?

You thirsty in the river? It's all there, if you'd look. In fact, you could just copy and paste.



BKBK
Community Expert
Community Expert
September 27, 2008
I suppose Adam means you should read up on the two approaches he mentions. Take it from here

<!--- text content --->
<cfsavecontent variable="x">
<DeliveryReport><message id="1023012301" sentdate=""
donedate="2005/7/19 22:0:0" status="NOT_SENT" /></DeliveryReport>
</cfsavecontent>

<!--- convert text to XML object --->
<cfset xmlObj = xmlParse(x)>

<!--- extract message id using Coldfusion's XML functionality --->
<cfset msgID = xmlObj.xmlRoot["message"].XmlAttributes["id"]>
message id = <cfoutput>#msgID#</cfoutput>

September 27, 2008
ok thanks that works i also have another format, but i am still not sure how to access the values

<test>
<authentification>
<username>usrn</username>
<password>ese45ss</password>
</authentification>
</test>

so how do i go down the children to get the value?
Inspiring
September 27, 2008
What of the online documentation about CF's XML processing (or even string
processing) functions have you read and tried to get working?

Where' some code you've tried to get the relevant values out? In what way
does the code not work?

For starters:
XML approach:
http://livedocs.adobe.com/coldfusion/8/functions-pt0_21.html#3468770

String approach:
http://livedocs.adobe.com/coldfusion/8/htmldocs/functions-pt0_18.html#1099887

--
Adam
September 27, 2008
Hi yes i have tried several things i ended up with this

<cfset x = GetHttpRequestData().content>
#x.DeliveryReport.message id#<br>
#x.DeliveryReport.status#<br>