Reputation: 187
I have this xml
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<loginResponse xmlns="http://www.tedial.com/3rdparty/"
xmlns:ns2="http://www.tedial.com/apiextension/">
<session>1C7AE89A-73BF-01E9-9D3F-0010007FFF00</session>
</loginResponse>
</S:Body>
</S:Envelope>
I was trying so many combinations but I am unable to get the session value. Can you help me?
I tried //S:Envelope//S:Body//ns2:loginResponse//ns2:session
with no luck
Upvotes: 0
Views: 222
Reputation: 187
I got it working now. The problem was happening in SoapUI. For some reason Soap UI automatically uses namespaces for the default namespaces starting with ns1. In my case this Xpath expression worked fine: //S:Envelope//S:Body//ns1:loginResponse//ns1:session
Upvotes: 0
Reputation: 29022
You used a wrong namespace on the session
element. The default namespace of loginResponse
- xmlns="http://www.tedial.com/3rdparty/"
- is inherited to the session
element. You have to use the same namespace as
with loginResponse
which you - erroneously - assigned the ns2
namespace. So define a third namespace prefix for http://www.tedial.com/3rdparty/
- here I used third
- and use that for loginResponse
and session
:
/S:Envelope/S:Body/third:loginResponse/third:session
Upvotes: 2
Reputation: 12169
Try this:
//S:Envelope//S:Body/loginResponse/session/text()
ns2 prefix not needed.
Upvotes: 0