3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = <<<XML <?xml version="1.0" encoding="ISO-8859-1"?> <PersonList> <Header> </Header> <Person> <Name id="35" nume="LOL">Sonu Kapoor</Name> <Age>24</Age> <Gender>M</Gender> <PostalCode>54879</PostalCode> </Person> <Person> <Name>Jasmin</Name> <Age>28</Age> <Gender>M</Gender> <PostalCode>78745</PostalCode> </Person> <Person> <Name>Josef</Name> <Age>232</Age> <Gender>F</Gender> <PostalCode>53454</PostalCode> </Person> </PersonList> XML; $doc = new DOMDocument(); $doc->loadXML($content); $xp = new DOMXPath($doc); foreach ($xPath->query('//PersonList/Person/Name') AS $Name) { $ID = $Name->getAttribute('id'); $Atrib = $Name->getAttribute('nume'); if($Atrib != "") { $Name->setAttribute('nume','Nuevo'); } } $doc->formatOutput = true; echo $doc->saveXML();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $xPath in /in/qaFKW on line 32 Fatal error: Uncaught Error: Call to a member function query() on null in /in/qaFKW:32 Stack trace: #0 {main} thrown in /in/qaFKW on line 32
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.72 ms | 401 KiB | 8 Q