seeraig
asked on
Coldfusion XML
Trying to extract some xml data and having some problems. I'm using CFHTTP to send data and then reading the xml response. I just need to grab the "InvQTY" number from the xml response, what is the best way to do that (i've attached a pic of the xml output). Here is my code which is not working:
<cfset myxml = XmlParse(CFHTTP.FileConten t)>
<cfset myxml = XmlParse(CFHTTP.FileConten t)>
<cfdump var="#myxml#">
<CFSET GetInv = xmlSearch(myxml,'/InvQty') >
<CFSET QtyXML = xmlparse(GetInv) />
<CFSET InventoryQTY = QtyXML.xmlText>
<cfset myxml = XmlParse(CFHTTP.FileConten
<cfset myxml = XmlParse(CFHTTP.FileConten
<cfdump var="#myxml#">
<CFSET GetInv = xmlSearch(myxml,'/InvQty')
<CFSET QtyXML = xmlparse(GetInv) />
<CFSET InventoryQTY = QtyXML.xmlText>
Btw: Why is this question under Jscript?
ASKER
Unfortunately that didn't work. This is my code and the InventoryQty variable returns the word 'Document'. If I just output the CFHTTP.FileContent variable, i get back the InvQty amount (25 in this example). But when I do an isnumeric on the CFHTTP.FileContent variable, it comes back as 'NO'.
<CFOUTPUT>
<cfset myxml = XmlParse(CFHTTP.FileConten t)>
<cfdump var="#myxml#">
<CFSET InventoryQTY = #myXML.xmlType#>
Inventory - #InventoryQTY#
</CFOUTPUT>
<CFOUTPUT>
<cfset myxml = XmlParse(CFHTTP.FileConten
<cfdump var="#myxml#">
<CFSET InventoryQTY = #myXML.xmlType#>
Inventory - #InventoryQTY#
</CFOUTPUT>
ASKER
Here is the http post so you can just see everything and see the response and probably figure it out way easier:
<CFHTTP METHOD="POST" URL="http://affiliate.strawberrynet.com/affiliate/cgi/QTYResponse.asp?ProdId=126496" THROWONERROR="YES">
</CFHTTP>
<CFHTTP METHOD="POST" URL="http://affiliate.strawberrynet.com/affiliate/cgi/QTYResponse.asp?ProdId=126496" THROWONERROR="YES">
</CFHTTP>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
> <cfdump var="#myxml#">
If that returns an "InvQty" node you should just be able to use:
#myXML.xmlType#
If not, can you post an example of the CFHTTP.FileContent string?