0

I need to grab and print a value of a Soap XML object using PHP.

I tried with this but I get no results:

echo $token->soap:envelope->soap:body->authenticationuserresponse->authenticationuserresult;

And also this one:

echo $token->envelope->body->authenticationuserresponse->authenticationuserresult;

Take a look at the capture to see what I mean:

enter image description here

JPashs
  • 13,044
  • 10
  • 42
  • 65
  • 1
    Is this message coming through a normal HTTP request, or are you using the built-in [SOAP client](https://stackoverflow.com/a/4195132/231316) which provides ready access to these? – Chris Haas May 20 '23 at 14:03
  • @ChrisHaas the xml comes from a HTTP request. Can you help me please. The duplicated question is not helping me at all. Thanks. – JPashs May 21 '23 at 17:40
  • 1
    I’m willing to help, but you need to post some code, no screenshots. Please include the actual XML, how you are loading it, and how you are attempting to parse it. – Chris Haas May 21 '23 at 20:32
  • @ChrisHaas This is the actual xml: https://www.pakot.com/AuthenticationUser3.xml I need to print out the AuthenticationToken in my screen using php 'echo'. – JPashs May 23 '23 at 16:44
  • 1
    As noted in the answer that this was marked as a duplicate of, in order to access anything within a namespace you just need to qualify it. See this for two versions of doing that: https://3v4l.org/hUBWs. Both could use lots of checks because there's lots of places where null or incorrect index assumptions might happen, but I'll leave that to you. In the long run, seriously consider making your initial call that happens _before_ this use the native SOAP clint – Chris Haas May 23 '23 at 17:57
  • Hi @ChrisHaas thanks! One last thing. I'm trying to modify your example to output each 'stocks' using a foreach() loop but I can't get it. Can you please take a look and tell me what is wrong? https://3v4l.org/LXKBE – JPashs May 24 '23 at 07:54

0 Answers0