3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <toflag> <flagarea formulaid="1" eventid="100" sessionid="421" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="207" sessionid="423" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="94" sessionid="117" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="120" sessionid="155" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> </toflag> XML; $dom = new DOMDocument; $dom->loadXML($xml); $dom->formatOutput = true; $xpath = new DOMXpath($dom); $query = '/toflag/flagarea[@formulaid="1" and @eventid="207" and @sessionid="423" and @sectionid="180001" and @floorid="180001" and @zoneid="180001" and @categoryid="180001"]/flagbloc[@priceid="4410026"]'; $result = $xpath->query($query); if ($result->length) { $flagBloc = $result->item(0); var_dump($flagBloc, $flagBloc->nodeValue); } echo $dom->saveXML();
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.6.28, 7.0.0 - 7.1.0
object(DOMElement)#3 (18) { ["tagName"]=> string(8) "flagbloc" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(8) "flagbloc" ["nodeValue"]=> string(1) "1" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(8) "flagbloc" ["baseURI"]=> string(1) "/" ["textContent"]=> string(1) "1" } string(1) "1" <?xml version="1.0" encoding="utf-8"?> <toflag> <flagarea formulaid="1" eventid="100" sessionid="421" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="207" sessionid="423" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="94" sessionid="117" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="120" sessionid="155" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> </toflag>
Output for hhvm-3.12.0
object(DOMElement)#3 (18) { ["nodeName"]=> string(8) "flagbloc" ["nodeValue"]=> string(1) "1" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(8) "flagbloc" ["baseURI"]=> string(1) "/" ["textContent"]=> string(1) "1" ["tagName"]=> string(8) "flagbloc" ["schemaTypeInfo"]=> NULL } string(1) "1" <?xml version="1.0" encoding="utf-8"?> <toflag> <flagarea formulaid="1" eventid="100" sessionid="421" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="207" sessionid="423" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="94" sessionid="117" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="120" sessionid="155" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> </toflag>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.3.10, 5.4.0
object(DOMElement)#3 (0) { } string(1) "1" <?xml version="1.0" encoding="utf-8"?> <toflag> <flagarea formulaid="1" eventid="100" sessionid="421" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="207" sessionid="423" sectionid="180001" floorid="180001" zoneid="180001" categoryid="180001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="94" sessionid="117" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> <flagarea formulaid="1" eventid="120" sessionid="155" sectionid="170001" floorid="0" zoneid="170001" categoryid="170001"> <flagbloc priceid="4410026">1</flagbloc> </flagarea> </toflag>
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/oe0eq on line 20
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/oe0eq on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/oe0eq on line 20