XML Tag Text in PHP

Suppose we have one tag in XML:

test.xml<root>
  <tag>text</tag>
</root>

Let's get the text of this tag. Its value will be stored in the property of the object $xml:

index.php<?php
  echo $xml->tag; // outputs 'text'
?>
Задание 1

Given the following XML:

html<root>
  <name>john</name>
</root>

Display the user's name.

Задание 2

Given the following XML:

html<root>
  <user>
    <name>john</name>
    <surn>smit</surn>
  </user>
</root>

Display the user's first and last name.