1

I'm very new to XML and web services so I'm looking for some direction. I have a classic ASP web app (OK no jokes!) that is using a web service to retrieve data from a DB. I'm able to call the web service and receive the SOAP response just fine. My problem comes when trying to parse the response. My code to call the web service goes like this...

Dim objXMLHttp, strEnvelop, strReturn
strEnvelope = <I build the soap message here>
set objXMLHttp = Server.CreateObject("MSXML2.XMLHTTP")
objXMLHttp.open "POST", "web service URL", false
objXMLHttp.setRequestHeader "Content-Type", "text/xml"
objXMLHttp.send strEnvelope
strReturn = objXMLHttp.responseText

All of that works perfectly and strReturn has the response XML in it. The XML will look something like this...

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<lookupCaseOutputCollection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/lookupCase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<lookupCaseOutput>
<C_CASE_ID>100000</C_CASE_ID>
<I_FIRST_NM>BERNADINE</I_FIRST_NM>
<I_MI_NM>C</I_MI_NM>
<I_LAST_NM>TWOTEETH</I_LAST_NM>
<I_DOB_DT>1977-06-26</I_DOB_DT>
</lookupCaseOutput>
</lookupCaseOutputCollection>
</Body>
</Envelope>

When it comes time to parse the response XML I get as far as...

Dim xmlDoc
set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.async = false
xmlDoc.Load strReturn

That's where I get stuck. I need to be able to extract and display the values of the individual tags C_CASE_ID, I_FIRST_NM, etc. I'm at a loss for how to do this. Does anyone have any suggestions/examples?

Thanks.

1
  • Of course as soon as I posted this question I looked over under the "related" topics and found a topic that answered my question perfectly. Of course it didn't show in any of the searches I did before posting. Figures :-) Commented Mar 7, 2013 at 17:28

1 Answer 1

4

First of all you need loadXML, not load, to load XML data from a string. The latter is for loading XML data from a file.

Once you parsed the structure into the DOMDocument object you can use the documented properties and methods. I'd recommend using selectNodes() or selectSingleNode() with an XPath expression for selecting the nodes you're interested in:

xmlDoc.loadXML strReturn

WScript.Echo xmlDoc.selectSingleNode("//C_CASE_ID").text
WScript.Echo xmlDoc.selectSingleNode("//I_FIRST_NM").text
'...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.