How to get element name for varying localname



My xml is like this i wish to get the element name of the below xml. my issue in my request i want to get the Payload element for that i used this expression


name(//env:Payload) So i am getting this result env:Payload



<env:requeset xmlns:env="http://ift.tt/1kvACzw" xmlns:ggg="http://fai.dgn.sss/ggg">
<env:clientbody>
<env:Payload>
<ggg:Service>
<ggg:Request>
<a>name</a>
<b>age</b>
<c>address</c>
</ggg:Request>
</ggg:Service>
</env:Payload>
</env:clientbody>
</env:requeset>


But some times my client sending request with different elements and some times without namespace also.So how would i get the below request also



<requeset xmlns:="http://ift.tt/1kvACzw" xmlns:ggg="http://fai.dgn.sss/ggg">
<clientbody>
<Payload>
<ggg:Service>
<ggg:Request>
<a>name</a>
<b>age</b>
<c>address</c>
</ggg:Request>
</ggg:Service>
</Payload>
</clientbody>
</requeset>


For above request i am using same expression so its giving errors so how would i get the Payload element in 2 cases or any case I have tried with this but its not working name(//( local-name()='Payload'))


Its giving ERROR - Failed to evaluate XPath expression: A location step was expected following the '/' or '//' token.


So please guide to get that element without namespace and different namespaces also I have tried with Contains expression also but I am unable to get that.


Thanks in advance.


No comments:

Post a Comment