Getting attribute value from DOMXPath query result?

HeadShot

New Member
I'm trying to search an XML file and return all the data for the record that matches the given criteria. Here is something like I have now, it searches fine, but I can't seem to figure out how to get the value of other attributes within that same record.Here is a sample of the XML file that would be used:\[code\]<routing> <route> <url>/homepage</url> <file>/pages/home.php</file> </route></routing>\[/code\]And here is how I'm finding a specific record or records within the document. It finds them perfectly, but how can I get the data from the record that was matched?\[code\] $qExp = '//route'; foreach($inst->query($qExp) as $key=>$node) { print_r($node); // echo $node->file->nodeValue; // how would I do this? I can't seem to // access specific attributes at all // inside of the DOMXPath class }\[/code\]A DOMXPath object will be stored in \[code\]$node\[/code\], but how can I use the \[code\]DOMXPath\[/code\] object to get other attribute values? For instance, the first XML record would be returned by this query, but how would I get the value of the \[code\]file\[/code\] attribute specifically? I know there is a \[code\]nodeValue\[/code\] function available, but it returns all the field's values together and I'm not able to sort through which parts belong to which fields.Thanks in advance for any help, this has really been bugging me.
 
Back
Top