0

I'm running this code in php

$xml = simplexml_load_file("test_info.xml");
$xml_image = $xml->channel->userinfo->image;

test_info.xml:

<channel>
 <userinfo>
  <image>somewhere</image>
 </userinfo>
</channel>

it should return -somewhere- as it's <image>'s content, but it's returning a blank output. What am I doing wrong? I cant find anything better.

1 Answer 1

3

Leave out <channel>, it's represented by $xml.

$xml_image = $xml->userinfo->image;
Sign up to request clarification or add additional context in comments.

Comments

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.