0

i've got an xml-string in $response that looks like this:

<?xml version="1.0"?>
<RESPONSE>
  <ERROR>
    <ERROR_CODE>6</ERROR_CODE>
    <ERROR_TEXT>Authentication failed</ERROR_TEXT>
  </ERROR>
</RESPONSE>

In order to read it, I run

$xml_response = simplexml_load_string($response);

The problem is:

$xml_response->getName();

returns - as expected - "RESPONSE", but

isset($xml_response->RESPONSE->ERROR->ERROR_TEXT); 

returns FALSE - but why? Any ideas?

Thanks in advance!

1
  • $xml_response is the root node. That's why you should call it $RESPONSE instead, to avoid the confusion. Commented Feb 13, 2011 at 14:32

1 Answer 1

3

Try without the root node when accessing the path that you want:

isset($xml_response->ERROR->ERROR_TEXT); 
Sign up to request clarification or add additional context in comments.

1 Comment

Yep, that was the problem! Thanks a lot! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.