I'm glad that removing the '*' from the XPath statement worked. I believe I can provide a more detailed explanation. Your original XPath statement was looking for ns2:errorCode
and ns2:message
one level underneath the root node. By removing the asterisk from the XPath and using //
shortcut to begin the search you're actually searching the entire document for any elements name ns2:errorCode
and ns2:message
.
One side note, this is actually less efficient as the parser has to go through all elements. A more efficient XPath statement is /soapenv:Envelope/soapenv:Body/ns2:Fault/detail/ns2:InternalSystemErrorException/ns2:errorCode
and ns2:message
. By specifying the full path you're telling the parser exactly where to look for your nodes. Take a look at point #9 on this page.