Query a SOAP Response Body with Xpath in Web Request Control

  • 15 February 2022
  • 0 replies
  • 668 views

Userlevel 2
Badge +9

Topic

Using Xpath to parse XML containing  namespaces in the Web Request control.

 

Instructions

To successfully query XML containing  namespaces in the Web Request control you must add wild cards for each element after the last element containing a namespace. Alternatively, you can bypass all nodes and find only the desired node.


Example XML Response:
<?xml version="1.0" encoding="utf-8"?>
<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>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>2</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>

 

Example XPath queries:

 

wildcards after namespace
/soap:Envelope/soap:Body/*/*

 

selecting only desired nodes:

//*[local-name()='AddResult']

 

0 replies

Be the first to reply!

Reply