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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WEBSERVICE - XML - SOAP - ASP

Status
Not open for further replies.

celley

Programmer
Jul 31, 2000
54
0
0
A2
I am making a webservice call in ASP via SOAP. Everything is working fine, except for when my webservice response is returning a XML object. I dont know how I need to parse through this object in ASP. Any ideas?
 
Two objects that could be helpful in your search are XMLHTTP and the XMLDOM objects. Basically what you will want to do is instantiate and XMLDOM object and use it's built in .LoadXML xmlstring method to load the reply into the object. Than using other methods from the XMLDOM object you can get specific information out of the document. I would suggest looking at the MSDN reference on the XMLDOM object.

If you are only attempting to get two or three pieces of data out of the xml and they are always inside the same set of unique tags, you could cheat and use InStr's and mid's to grab data out of those tags.
basically you would do something along the lines of:
Code:
Function getValue(tagname,xmlstring)
   Dim startPos  
   startPos = InStr(xmlstring,&quot;<&quot;&tagname&&quot;>&quot;)+len(tagname)+2
   getvalue = mid(xmlstring,startPos,InStr(xmlstring,&quot;</&quot;&tagname&&quot;>&quot;)-startPos-1)
End Function

Dim myXMl
myXMl = &quot;<test><quantity>4</quantity><item><price>5.25</price><action>sell</action></item></test>&quot;

Dim qty, prc, act
qty = getValue(&quot;quantity&quot;,myXML)
prc = getValue(&quot;price&quot;,myXML)
...etc

The above code was on the fly, I think i lined up the position and length in the mid correctly but it may need to be finessed.

While the logic in the above code would work for XML that always had the same exact structure with no duplicate tags and no null tags, etc I would still suggest that you find some references and examples on using MS XMLDOM as very few xml documents will be structured that exactly.

-Tarwn &quot;If you eat a live toad first thing in the morning, nothing worse will happen all day long.&quot; - California saying
&quot;To you or the toad&quot; - Niven's restatement of California saying
&quot;-well most of the time anyway...&quot; - programmers caveat to Niven's restatement of California saying
(The Wiz Biz - Ri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top