rossh Posted March 3, 2010 Share Posted March 3, 2010 Hi I have the following code to filter xml data. I'm now able to query the xml file, but the results are not well formed, so i can't output specific elements. Does anyone know how to return element names and values from DomXpath? <?php $reader = new XMLReader(); $reader->open('include/staff.xml'); while ($reader->read()){ switch($reader->nodeType){ case(XMLREADER::ELEMENT): if($reader->localName === 'staff'){ $node = $reader->expand(); $dom = new DomDocument(); $dom->formatOutput = true; $n = $dom->importNode($node, true); $dom->appendChild($n); $xp = new DomXpath($dom); $res = $xp->query("//staff/member[groups='HR']"); } } } foreach($res as $staff){ echo $staff->nodeValue; } ?> Link to comment https://forums.phpfreaks.com/topic/194017-xmlreader-domxpath/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.