0

Hi all,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ABC="http://www.ABCSPGM.DSUPFREQ.Request.com">
<soapenv:Header>
<ABC:ABCSHeader>
<ID>xyz</ID>
<ConsumerTransactionId>5667</ConsumerTransactionId>
</ABC:ABCSHeader>
</soapenv:Header>
<soapenv:Body>
<ABC:ABCSPGMOperation>
<ABC:req>
<ABC:plastic_number>1234</ABC:plastic_number>
</ABC:req>
</ABC:ABCSPGMOperation>
</soapenv:Body>
</soapenv:Envelope>

The above is my input passed by the client. How can I extract the values within the tag 'ID','ConsumerTransactionId' and 'ABC:plastic_number' using simple xpath expressions.

I know that if we give

/*[namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/' and local-name()='Envelope']/*[namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/' and local-name()='Header']/*[namespace-uri()='http://www.ABCSPGM.DSUPFREQ.Request.com' and local-name()='ABCSHeader']/ID
this will fetch me the value of automation id

However instead of the above long expression is there a way to generalize such that I can search for the first occurence of 'ID' and take the value

something like
//*[local-name() = 'ID']

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by iceandrews
0

It works with /*/*/*/ID for ID

Is there a method to get an expression like /*/*/*/ID for plastic-number as well. This has a namespace compared to others.

0

why not just //ID for the first?

//ABC:plastic_number

there's nothing to stop from using the fully qualified name in the xpath.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.