Home > Software design >  How to get XML namespace value via Xpath
How to get XML namespace value via Xpath

Time:10-20

How can i get the "273" value of ns1:bookId, when I have an xml response like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <ns2:createResponse ns1:bookId="273" xmlns:ns1="http://www.example.com/">
   </soap:Body>
</soapenv:Envelope>

SoapUI doesn't accept this pattern: //ns2:createResponse/@ns1:bookId

CodePudding user response:

You can ignore namespaces in XPath:

//*[local-name()="createResponse"]/@*[local-name()="bookId"]
  • Related