What is the XPath of an element in a different default namespace?

I am considering this SOAP answer:

<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>
      <StartProcessFileResponse xmlns="http://www.abbyy.com/RecognitionServer4_xml/RecognitionServer4.xml">
         <StartProcessFileResult>{B4815D0C-91F9-4BD3-BF2F-3A70E935AA7B}</StartProcessFileResult>
      </StartProcessFileResponse>
   </soap:Body>
</soap:Envelope>

      

I need to get XPath for an element StartProcessFileResult

, but when I try this XPath in online authentication, I don't get any match:

/soap:Envelope/soap:Body/StartProcessFileResponse/StartProcessFileResult

      

I tried a smaller part of XPath and this XPath /soap:Envelope/soap:Body

returns an element <body>

, but when I go further and try to access StartProcessFileResponse

using this XPath /soap:Envelope/soap:Body/StartProcessFileResponse

, I don't get a match.

What am I doing wrong?

+3


source to share


1 answer


StartProcessFileResult

is in the http://www.abbyy.com/RecognitionServer4_xml/RecognitionServer4.xml

default namespace .

Using the namespace bindings of your XPath library, bind the namespace prefix, say rs

- http://www.abbyy.com/RecognitionServer4_xml/RecognitionServer4.xml

.

Then the following XPath will select StartProcessFileResult

as requested:

/soap:Envelope/soap:Body/rs:StartProcessFileResponse/rs:StartProcessFileResult

      



If you cannot concatenate the namespace prefix, you can use the function local-name()

,

/soap:Envelope/soap:Body/*[local-name()='StartProcessFileResponse']/*[local-name()='StartProcessFileResult']

      

but the preferred way is to create and use a namespace prefix binding.

+3


source







All Articles