XML Tag Names With Hyphens in PHP
Suppose a tag name contains a hyphen:
<root>
<tag>
<elem-child>text</elem-child>
</tag>
</root>
In this case, to access such a tag, you will need to use the following technique:
<?php
echo $xml->tag->{'elem-child'}; // 'text'
?>
Given the following XML:
<root>
<user-name>john</user-name>
<user-surn>smit</user-surn>
</root>
Display the user's first and last name on the screen.