3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<?xml version="1.0" encoding="UTF-8"?><ns3:entDocumentResponse xmlns="http://domain.com/dictionary/technical/" xmlns:ns2="http://domain.com/services/entityService/document/GetContentUrl_1_0" xmlns:ns3="http://domain.com/services/entityService/document/1.0"> <activities/> <ns3:response> <ns3:opGetContentUrl_1_0> <ns2:documentContentUrl>https://server.domain.com/ACS/servlet/someUrl</ns2:documentContentUrl> </ns3:opGetContentUrl_1_0> </ns3:response> </ns3:entDocumentResponse>'; // situation 1 $xml = new \DOMDocument(); $xml->loadXML($str); $xpath = new \DOMXPath($xml, false); $xpath->registerNamespace('ns3', 'http://domain.com/services/entityService/document/1.0'); $xpath->registerNamespace('ns2', 'http://domain.com/services/entityService/document/GetContentUrl_1_0'); $res = $xpath->evaluate('/ns3:entDocumentResponse/ns3:response/ns3:opGetContentUrl_1_0/ns2:documentContentUrl'); if ($res instanceof \DOMNodeList && $res->length > 0) echo '[1] ', $res->item(0)->nodeValue, "\n"; else echo '[1] ', 'Not parsed for situation 1.', "\n"; // situation 2 $xml2 = new \DOMDocument(); $xml2->loadXML($str); $xpath2 = new \DOMXPath($xml2, false); $xpath2->registerNamespace('ns2', 'http://domain.com/services/entityService/document/1.0'); $xpath2->registerNamespace('ns3', 'http://domain.com/services/entityService/document/GetContentUrl_1_0'); $res = $xpath2->evaluate('/ns2:entDocumentResponse/ns2:response/ns2:opGetContentUrl_1_0/ns3:documentContentUrl'); if ($res instanceof \DOMNodeList && $res->length > 0) echo '[2] ', $res->item(0)->nodeValue, "\n"; else echo '[2] ', 'Not parsed for situation 2.', "\n"; // situation 3 $xml3 = new \DOMDocument(); $xml3->loadXML($str); $xpath3 = new \DOMXPath($xml3, false); $xpath3->registerNamespace('a', 'http://domain.com/services/entityService/document/1.0'); $xpath3->registerNamespace('b', 'http://domain.com/services/entityService/document/GetContentUrl_1_0'); $res = $xpath3->evaluate('/a:entDocumentResponse/a:response/a:opGetContentUrl_1_0/b:documentContentUrl'); if ($res instanceof \DOMNodeList && $res->length > 0) echo '[3] ', $res->item(0)->nodeValue, "\n"; else echo '[3] ', 'Not parsed for situation 3.', "\n";
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.5.0
[1] https://server.domain.com/ACS/servlet/someUrl [2] https://server.domain.com/ACS/servlet/someUrl [3] https://server.domain.com/ACS/servlet/someUrl
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
51.1 ms | 407 KiB | 5 Q