3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str=<<<XML <scales> <scale id="1" gender="v"> <d>5</d> <d>9</d> </scale> <scale id="2" gender="m" age="*"> <d>3</d> <d>0</d> </scale> <scale id="3" gender="*" age="19-39"> <d>12</d> <d>19</d> </scale> </scales> XML; $xml=simplexml_load_string($str); $result=$xml->xpath('//scale[@age]'); foreach($result as $node) { echo $node->attributes()->id."\n"; }
based on FMmCT
Output for 5.6.0 - 7.3.0beta1
2 3