• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

xml post Urgent

Guest
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

787

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

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

And I presume that didn't work (typo in the second line aside)?

According to the docs for getHttpRequestData():
http://livedocs.adobe.com/coldfusion/8/functions_e-g_43.html

the "content" key will be a string.

So the first question is: can one take a STRING and refer to it as if it's
a structure like you have? I get this error:

{quote}
You have attempted to dereference a scalar variable of type class
java.lang.String as a structure with members.
{quote}

So I'm guessing "no" (actually I know so, but I'm trying to approach this
from an POV of trying to work it out for the first time).

So one cannot see some XML in a string and hope CF will also work out that
you want the string to be treated as XML. You might need to convert the
string to XML first.

This should lead you to investigate how to do that, and I suspect that if
you're read any of the docs I pointed you to, you'd have got at least that
far. So I'm guessing you *didn't* bother to read those docs, so I'm kinda
wondering whether you actually *do* want to work this out.

But anyway, if you're prepared to try to help yourself, I'm prepared to try
to help you with that. Read the docs I pointed you to. They are not a
random selection, they are the ones you will need to crack this one. Read
up on xmlParse(), and then how to refer to elements within an XML doc.
There are examples of this in the docs.

I'm about to go out, but will check back here in a couple of hours to see
if you've made any progress.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 27, 2008 Sep 27, 2008

Copy link to clipboard

Copied

> so how do i go down the children to get the value?

Have a look at how the xmlAttributes and xmlText are accessed in the sample
code here:
http://livedocs.adobe.com/coldfusion/8/functions_t-z_22.html

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2008 Sep 28, 2008

Copy link to clipboard

Copied

LATEST
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.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation