3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = '<lib id="ITEM_I_WANT_TO_DOWNLOAD_1" revision="0000"> <part id="0000" type="ch"/> <part id="0000" type="ls"/> <part id="0000" type="rs"/> <part id="0000" type="ch"/> </lib> <lib id="ITEM_I_WANT_TO_DOWNLOAD_2" revision="0000"> <part id="0000" type="ch"/> <part id="0000" type="ls"/> <part id="0000" type="rs"/> <part id="0000" type="ch"/> </lib>'; $document = new DOMDocument(); $document->loadXml($xml); $xpath = new DOMXpath($document); foreach ($xpath->evaluate('//lib/@id') as $attr) { $result[] = $attr->value; } var_export($result);
based on ZrEas
Output for 5.6.38 - 7.3.0rc3
Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 7 in /in/20SAp on line 16 Notice: Undefined variable: result in /in/20SAp on line 21 NULL