XML Tag Attributes in PHP
Now let the tag have attributes:
<root>
<tag attr="val">text</tag>
</root>
To get the attribute value,
you need to access $xml->tag
as an array:
<?php
echo $xml->tag['attr']; // outputs 'val'
?>
However, if you simply output $xml->tag,
you will get the tag text:
<?php
echo $xml->tag; // outputs 'text'
?>
Given the following XML:
<root>
<user age="23" salary="1000">john</user>
</root>
Display the user's name, age, and salary.