techco1
techco1

Reputation: 61

Question regarding simplexml_load_file, root element and document element

I am sure I am being an idiot here, but something is not working correctly.

I've got this very basic code.

$Xml = simplexml_load_file($Url);

If I do a debug print of $xml it comes out like I expect it to. The XML looks like this, very simple

<Root>
   <Error>
        <ErrorNo>0</ErrorNo>
   </Error>
</Root>

All I want to do is get the error number. So I have tried this, and it doesn't return anything!

echo $Xml->Root->Error->ErrorNo;

What am I doing wrong!?

Upvotes: 1

Views: 211

Answers (1)

Mihai Iorga
Mihai Iorga

Reputation: 39704

take out Root ... as Root becomes the $Xml element

echo $Xml->Error->ErrorNo;

Upvotes: 3

Related Questions