Skip to main content
Inspiring
March 4, 2009
Answered

Xml content element problem

  • March 4, 2009
  • 6 replies
  • 621 views
hello,

I make a SOAP request using cfhttp and I ‘ve to display the amount I get.
I get the values using the following code:

<CFSet xmlDoc = XMLParse(cfhttp.filecontent)>
<CFDump var="#xmlDoc#">

but
#xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren [1]. Amount#

returns: 29015

i can’t divide this value because it ‘s not numeric
In fact, when I use htmleditformat =>
#htmleditformat (xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren [1]. Amount) #
it returns
<?xml version="1.0" encoding="UTF-8"?> <Amount xmlns=" http://tempuri.org/">29015</ Amount >

How can I get directly the numerical value 29015 so that I can divide it by 100 and display 290,15

thank you in advance
This topic has been closed for replies.
Correct answer SamMagic
I found it :-)

the response was XmlText not XmlValue

#xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
[1].Amount.XmlText# return the correct value ;-)

thanks a lot

MAgic


6 replies

Inspiring
March 9, 2009
SamMagic wrote:
> I found it :-)
>
> the response was XmlText not XmlValue
>
> #xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
> [1].Amount.XmlText# return the correct value ;-)

Sorry, my mistake. XmlText is correct.

--
Mack
SamMagicAuthorCorrect answer
Inspiring
March 5, 2009
I found it :-)

the response was XmlText not XmlValue

#xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
[1].Amount.XmlText# return the correct value ;-)

thanks a lot

MAgic


Inspiring
March 4, 2009
> #xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
> [1].Amount.XmlValue#

As per my earlier comment:
>> I presume this is a node?
>> In which case you want the ***xmlText*** of the node, not the whole thing.

(note my emphasis)


> I've already read doc but without success

I think you need to read them a bit more thoroughly. It's pretty well
spelled out here:
http://livedocs.adobe.com/coldfusion/8/htmldocs/XML_08.html#1127795

(which is the fourth page of the stuff I suggested you reading last time)

I'm not trying to be "funny", it is worth reading this stuff throughly:
there's a lot of good info in there.

Read it, try the code, modify the code and try to predict the results, etc.
If you don't completely understand something, stick at it until you do.
Then it'll sink in.


--
Adam
SamMagicAuthor
Inspiring
March 4, 2009
Thanks Mack and Adam for replies :-)

I've already read doc but without success
i've tried

#xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
[1].Amount.XmlValue#

but it gives me an empty value, nothing to display

even
#len(xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
[1].Amount.XmlValue)#
returns 0

i'm sure that it s something simple to do but what ??

thanks for your help

Inspiring
March 4, 2009
> #xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren [1]. Amount#

I presume this is a node? IN which case you want thr xmlText of the node,
not the whole thing.

It might be an idea to review the docs on this, to get a clearer
understanding of how it works:
http://livedocs.adobe.com/coldfusion/8/XML_01.html

--
Adam
Inspiring
March 4, 2009
SamMagic wrote:
> hello,
>
> I make a SOAP request using cfhttp and I ?ve to display the amount I get.
> I get the values using the following code:
>
> <CFSet xmlDoc = XMLParse(cfhttp.filecontent)>
> <CFDump var="#xmlDoc#">
>
> but
> #xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren [1]. Amount#

You can access the value with XmlValue:

#xmlDoc.XmlRoot.XmlChildren [1]. XmlChildren [1]. XmlChildren
[1].Amount.XmlValue#

--
Mack