3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string = "<?xml version='1.0' encoding='UTF-8'?> <note> <to>Tove</to> <from>Jani</from> <heading>123</heading> <body>Don't forget me this weekend!</body> </note> "; $sxe = new SimpleXMLElement($string); $sxe->addAttribute('test', '2312'); echo $sxe->test; print_r($sxe);
based on 9JMMo
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc3
SimpleXMLElement Object ( [@attributes] => Array ( [test] => 2312 ) [to] => Tove [from] => Jani [heading] => 123 [body] => Don't forget me this weekend! )