I have this scenario, returned by a SOAP WS
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:myFunctionEnvelopeName xsi:type="xsd:string" xmlns:ns1="http://fooNameSpace.comm">
<myFunctionName xmlns="http://barNameSpace.com">
[some nodes here]
</myFunctionName>
</ns1:myFunctionEnvelopeName>
</soapenv:Body>
</soapenv:Envelope>
I want to select subnodes child of myFunctionName
but I have some issues
- If i register
ns1
namespace into myXPath
I'm able only to selectmyFunctionEnevelopeName
(even if I try withgetElementsByTagName()
I receive back 0 nodes - If I register, let's say,
ns2
withbarNameSpace.com
, my query will not return my elements- If I don't register any namespace my query will not return my elements
Only workaround I have found is to
- Register
ns1
as namespace ofXPath
- Retrieve "main node" (
myFunctionEnevelopeName
) - Extract
textContent
from "main node" (that of course is a valid xml) - Create a brand-new
Xpath
with the text content obtained - Register
ns2
as namespace of brand-newXpath
- Obtain what I want
I'm sure that exists a clever method to do that, but maybe I don't know it. Someone could give me pointers?