3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str=<<<XML <lookups> <lookup category="General" field="Country Code" value="FI" entityId="1" active="true" /> <lookup category="General" field="Country Name" value="Finland" entityId="2" active="true" /> <lookup category="General" field="Country Code" value="FI2" entityId="1" active="true" /> <lookup category="General" field="Country Name" value="Finland2" entityId="3" active="true" /> <lookup category="General" field="Country Code" value="FI3" entityId="1" active="true" /> <lookup category="General" field="Country Name" value="Finland3" entityId="4" active="true" /> <lookup category="General" field="Country Code" value="FI4" entityId="1" active="true" /> <lookup category="General" field="Country Name" value="Finland4" entityId="5" active="true" /> </lookups> XML; $xml=simplexml_load_string($str); $result=$xml->xpath('//lookup[@field="Country Code"]/@value'[@field="Country Name"]/@value'); foreach($result as $node) { echo $node; }
based on GkK7i
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.6
Parse error: syntax error, unexpected '=', expecting ']' in /in/Vsclg on line 15
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected '=', expecting ']' in /in/Vsclg:15 Stack trace: #0 {main}
Process exited with code 255.