querying soap result

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I get the following result from a webservice. I pass this string to an XML
Document. Can someone explain, how can I query the <result> out of the xml,
using xpath query language (ie. using selectsinglenode function)

Thanks,
Alwin S.


?xmlResult.xml
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<result>
<rows/>
</result>
</soap:Body>
</soap:Envelope>
 
Al,

The xpath expression you would want is:

soap:Body\result

That should give you the rows node.

However, I am curious, why not just set a web reference to the web
service, and use that? All the plumbing will be hooked up for you and you
don't have to worry about parsing this out yourself.

Hope this helps.
 
soap:Body/result didnt work.

Its referring to the soap namespace. I need to know how to query xml
containing namespace references.

We have a portability issue in our application that restricts us from using
soapclient or webreference for this project.

Alwin S.

Nicholas Paldino said:
Al,

The xpath expression you would want is:

soap:Body\result

That should give you the rows node.

However, I am curious, why not just set a web reference to the web
service, and use that? All the plumbing will be hooked up for you and you
don't have to worry about parsing this out yourself.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Al Sav said:
I get the following result from a webservice. I pass this string to an XML
Document. Can someone explain, how can I query the <result> out of the
xml,
using xpath query language (ie. using selectsinglenode function)

Thanks,
Alwin S.


?xmlResult.xml
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<result>
<rows/>
</result>
</soap:Body>
</soap:Envelope>
 
Al,

I forgot to mention, you have to set up the namespace alias on the
document so that it knows that "soap" maps to a particular namespace. You
would do this using the XmlNamespaceManager class, and then pass it in your
call to SelectNodes or SelectSingleNode.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Al Sav said:
soap:Body/result didnt work.

Its referring to the soap namespace. I need to know how to query xml
containing namespace references.

We have a portability issue in our application that restricts us from
using
soapclient or webreference for this project.

Alwin S.

Nicholas Paldino said:
Al,

The xpath expression you would want is:

soap:Body\result

That should give you the rows node.

However, I am curious, why not just set a web reference to the web
service, and use that? All the plumbing will be hooked up for you and
you
don't have to worry about parsing this out yourself.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Al Sav said:
I get the following result from a webservice. I pass this string to an
XML
Document. Can someone explain, how can I query the <result> out of the
xml,
using xpath query language (ie. using selectsinglenode function)

Thanks,
Alwin S.


?xmlResult.xml
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<result>
<rows/>
</result>
</soap:Body>
</soap:Envelope>
 
Back
Top