3v4l.org

run code in 300+ PHP versions simultaneously
<?php // "Create" the document. $xml = new DOMDocument( "1.0", "ISO-8859-15" ); $xml->xmlVersion = null; $xml->standalone = true; // Create some elements. $xml_album = $xml->createElement( "Album" ); $xml_track = $xml->createElement( "Track", "The ninth symphony" ); // Set the attributes. $xml_track->setAttribute( "length", "0:01:15" ); $xml_track->setAttribute( "bitrate", "64kb/s" ); $xml_track->setAttribute( "channels", "2" ); // Create another element, just to show you can add any (realistic to computer) number of sublevels. $xml_note = $xml->createElement( "Note", "The last symphony composed by Ludwig van Beethoven." ); // Append the whole bunch. $xml_track->appendChild( $xml_note ); $xml_album->appendChild( $xml_track ); // Repeat the above with some different values.. $xml_track = $xml->createElement( "Track", "Highway Blues" ); $xml_track->setAttribute( "length", "0:01:33" ); $xml_track->setAttribute( "bitrate", "64kb/s" ); $xml_track->setAttribute( "channels", "2" ); $xml_album->appendChild( $xml_track ); $xml->appendChild( $xml_album ); // Parse the XML. print $xml->saveXML();
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
<?xml version="" encoding="ISO-8859-15" standalone="yes"?> <Album><Track length="0:01:15" bitrate="64kb/s" channels="2">The ninth symphony<Note>The last symphony composed by Ludwig van Beethoven.</Note></Track><Track length="0:01:33" bitrate="64kb/s" channels="2">Highway Blues</Track></Album>

preferences:
229.23 ms | 405 KiB | 331 Q