3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Dom\XMLDocument; $xml = XMLDocument::createFromString(<<<EOXML <?xml version="1.0" encoding="UTF-8"?> <note xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="note-nonamespace1.xsd http://localhost/note-nonamespace2.xsd" xsi:schemaLocation="http://www.happy-helpers1.com note-namespace1.xsd http://www.happy-helpers2.com http://localhost/note-namespace2.xsd"> </note> EOXML ); $documentElement = $xml->documentElement; $attributes = $documentElement->attributes; $schemaLocation = $attributes->getNamedItemNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation'); var_dump(explode(' ', $schemaLocation->textContent ?? ''));
Output for 8.4.1 - 8.4.13
array(4) { [0]=> string(29) "http://www.happy-helpers1.com" [1]=> string(19) "note-namespace1.xsd" [2]=> string(29) "http://www.happy-helpers2.com" [3]=> string(36) "http://localhost/note-namespace2.xsd" }
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26
Fatal error: Uncaught Error: Class "Dom\XMLDocument" not found in /in/jjbDc:5 Stack trace: #0 {main} thrown in /in/jjbDc on line 5
Process exited with code 255.

preferences:
44.72 ms | 407 KiB | 5 Q