1

I new to web services response handling techniques. I have the soap response below, from which I want to get the UID value.

<Envelope xmlns:SOAP-ENV = "" SOAP-ENV:encodingStyle = "">
   <Body xmlns:m = ""> 
     <CreateUser>
     <m:status>SUCCESS</m:status>
     <m:code>1</m:code>
     <m:uid>1234t</m:uid>
   </CreateUser>
   </Body> 
</Envelope>

I tried this xpath traversal:

/Envelope/Body/CreateUser/m:uid

which yields:

<m:uid>1234t</m:uid>

I need just 1234t.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
mail4dwnld
  • 19
  • 4
  • 1
    Isn't what you get actually what you want? Please clarify your question. – Alexey R. Oct 06 '17 at 17:10
  • @AlexeyR.: It's the difference between selecting an element versus getting the string value of that element (or its child text node). [See below](https://stackoverflow.com/a/46612492/290085). – kjhughes Oct 06 '17 at 19:18

1 Answers1

1

If

/Envelope/Body/CreateUser/m:uid

yields

<m:uid>1234t</m:uid>

then

string(/Envelope/Body/CreateUser/m:uid)

and

/Envelope/Body/CreateUser/m:uid/text()

will yield

1234t

as requested.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Thanks for your reply. tried as suggested, it return blank value. – mail4dwnld Oct 08 '17 at 15:10
  • Then either `/Envelope/Body/CreateUser/m:uid` didn't return `1234t` as you say it did, or you're calling your XPath library improperly (and we can't comment on that since you've not shown it). – kjhughes Oct 08 '17 at 16:02