Add Child Nodes to XML String with PHP SimpleXML

<?php 

$s = '<?xml version="1.0" encoding="UTF-8"?>
<student>
    <id>st01</id>
	<name>Name 1</name>
</student>
';

$student = simplexml_load_string($s);

// email tag
$student->addChild('email', 'a@gmail.com');

// phone tag
$student->addChild('phone', '123456');

// address tag
$address = $student->addChild('address');
$address->addChild('street', 'street 1');
$address->addChild('ward', 'ward 1');

echo $student->asXML();

?>
<?xml version="1.0" encoding="UTF-8"?>
<student>
    <id>st01</id>
	<name>Name 1</name>
	<email>a@gmail.com</email>
	<phone>123456</phone>
	<address>
		<street>street 1</street>
		<ward>ward 1</ward>
	</address>
</student>