Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing Data From XML Array?

Status
Not open for further replies.

GDX

Programmer
Jun 4, 2000
186
US
Hello I am trying to place an XML Response into an array for easy parsing but im

having a very hard time doing this. Can someone please help me? We are using the SOAP

ToolKit with ASP (Not .NET). If you look at the results you will see that i am getting

back the data but now how do i loop through each "Product"? Below is a snippet of the

VBS I wrote:


Request.VBS
----------------------------------------

Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Set objOutputXMLDoc = CreateObject("MSXML.DOMDocument")
Set fileSys = Createobject ("Scripting.FileSystemObject")
set readfile = filesys.OpenTextFile("C:\Request.xml", 1, false)
contents = readfile.ReadAll
Msgbox contents
objXMLHTTP.open "post", "
False
objXMLHTTP.setRequestHeader "Content-Type", "text/xml"
objXMLHTTP.send contents

Msgbox objXMLHTTP.ResponseText ' <----Got Back Data Please see below for results

----------------------------------------


Results from Call
-------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

<soap:Envelope xmlns:n="xmlns:soap="xmlns:soapenc="xmlns:xs="xmlns:xsd1="xmlns:xsi="soap:encodingStyle="Search><result><xsd1:products soapenc:arrayType="xsd1:product[4]"
xsi:type="soapenc:Array"><item><xsd1:id>911395</xsd1:id><xsd1:partnum>BH0060
84 </xsd1:partnum><xsd1:name>POINTS
</xsd1:name><xsd1:altdesc>POINTS</xsd1:altdesc><xsd1:image>imc/images/tn/010
11.jpg</xsd1:image><xsd1:inventory1>219</xsd1:inventory1><xsd1:inventory2>0<
/xsd1:inventory2><xsd1:price>1.42</xsd1:price><xsd1:weight>0.05</xsd1:weight
><xsd1:eek:enumber>01011</xsd1:eek:enumber><xsd1:brand>Bosch</xsd1:brand></ite
>m><i
tem><xsd1:id>911414</xsd1:id><xsd1:partnum>BH006102
</xsd1:partnum><xsd1:name>POINTS (H.P.) </xsd1:name><xsd1:altdesc>POINTS

(H.P.)</xsd1:altdesc><xsd1:image>imc/images/tn/01030.jpg</xsd1:image><xsd1:i
nventory1>1440</xsd1:inventory1><xsd1:inventory2>329</xsd1:inventory2><xsd1:
price>5.10</xsd1:price><xsd1:weight>0.06</xsd1:weight><xsd1:eek:enumber>010
price>30</
xsd1:eek:enumber><xsd1:brand>Bosch</xsd1:brand></item><item><xsd1:id>993653</xs
d1:id><xsd1:partnum>BH078370 </xsd1:partnum><xsd1:name>POINTS
</xsd1:name><xsd1:altdesc>POINTS</xsd1:altdesc><xsd1:inventory1>219</xsd1:in
ventory1><xsd1:inventory2>0</xsd1:inventory2><xsd1:price>1.42</xsd1:pric
ventory1>e><x
sd1:weight>0.05</xsd1:weight><xsd1:eek:enumber>01111</xsd1:eek:enumber><xsd1:brand
>Bosch</xsd1:brand></item><item><xsd1:id>919916</xsd1:id><xsd1:partnum>B
>M047
350 </xsd1:partnum><xsd1:name>POINTS, NON HP
</xsd1:name><xsd1:altdesc>POINTS, NON
HP</xsd1:altdesc><xsd1:inventory1>87</xsd1:inventory1><xsd1:inventory2>11</x
sd1:inventory2><xsd1:listPrice>5.21</xsd1:listPrice><xsd1:price>2.00</xsd1:p
rice><xsd1:weight>0.05</xsd1:weight><xsd1:eek:enumber>12111267393</xsd1:eek:en
rice>umbe
r><xsd1:brand>Bremi</xsd1:brand></item></xsd1:products></result></n:part
r>numb
erSearch></soap:Body></soap:Envelope>

-----------------------------------------------




Gordon R. Durgha
gd@vslink.net
 
try this

Code:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM") 
objXMLDoc.async = False 
objXMLDoc.loadXml(objXMLHTTP.ResponseText) 

Set NodeList = objXMLDoc.documentElement.selectNodes("//soap:Body/n:partnumberSearch/result/xsd1:products") 
For Each Node In NodeList 
   document.write(Node.text & "<br>") 
Next

hth

simon

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top