Parsing xml with php and xpath
- by Hyung Suh
Hey guys,
I'm trying to parse an xml file to return a item with a specific id only, but having trouble
making it work.
here's what I have in php
$xml_str = file_get_contents("test.xml");
$xml = simplexml_load_string($xml_str);
$albid = $_GET['id'];
$nodes = $xml->xpath('//library/book[@id=1]');
foreach($nodes as $node) {
echo…