Add Attributes to Node in 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);

$dob = $student->addChild('dob', '20/10/2021');
$dob->addAttribute('pattern', 'dd/MM/yyyy');
$dob->addAttribute('place', 'Place 1');

echo $student->asXML();

?>
<?xml version="1.0" encoding="UTF-8"?>
<student>
    <id>st01</id>
	<name>Name 1</name>
	<dob pattern="dd/MM/yyyy" place="Place 1">20/10/2021</dob>
</student>