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 git.master_jit, git.master
[1] https://server.domain.com/ACS/servlet/someUrl [2] https://server.domain.com/ACS/servlet/someUrl [3] https://server.domain.com/ACS/servlet/someUrl

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:
49.59 ms | 405 KiB | 5 Q