Link to home
Start Free TrialLog in
Avatar of NELIXINC
NELIXINC

asked on

Need to remove Soap envelope to parse XML response

I am using asp.net 2.0 and a webservice that returns XML data as a string.
I am able successfully load the xml with XMLDocument.LoadXML(strXML). The response is inside a soap envelope in a plain text format.

How do I access the xml values ('LoginResponse' and SECTOKEN) as XML nodes without resorting to string manipulation (i.e. chopping off the soap enveleope, or using instr(SECTOKEN) to find the value).

That is, how do I remove the soap and get to the good stuff?

Example XML response below.

Thanks!
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:iws0005lResponse xmlns:ns="http://login.wsbeans.iseries/xsd"><ns:return><ns:_LS_OUTPUT_PARM_BUFF_STRUCT><ns:_LS_OUTPUT_PARM_BUFF>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#xD;
&lt;LoginResponse result="SUCCESS"&gt;&#xD;
&lt;SECTOKEN&gt;4BC952DED0D2BA39A714F3BEB2A8787D71041A02F60A1C5527807B&lt;/SECTOKEN&gt;&#xD;
&lt;/LoginResponse&gt;&#xD;
</ns:_LS_OUTPUT_PARM_BUFF><ns:_LS_OUTPUT_PARM_BUFF></ns:_LS_OUTPUT_PARM_BUFF><ns:_LS_OUTPUT_PARM_BUFF></ns:_LS_OUTPUT_PARM_BUFF><ns:_LS_OUTPUT_PARM_BUFF></ns:_LS_OUTPUT_PARM_BUFF></ns:_LS_OUTPUT_PARM_BUFF_STRUCT></ns:return></ns:iws0005lResponse></soapenv:Body></soapenv:Envelope>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of yesthatbob
yesthatbob
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NELIXINC
NELIXINC

ASKER

Thank you so much. You're code works beautifully. Thanks especially for plugging in the namespace values from my example code. That was the part I was missing completely, and now I'm beginning to understand it.