xpath search for a php variable

redskull

New Member
I am trying to search for a php variable in an xml file using xpath, but failing miserably. It works with a hard coded value, so I am nearly there..\[code\]<visitors> <detail> <id>876867</id> <name>Bob McHaggis</name> <email>[email protected]</email> </detail> <detail> <id>897987</id> <name>Mark McBob</name> <email>[email protected]</email> </detail></visitors><?php $sxe = simplexml_load_file("/CaptivePortal/visitors.xml"); foreach($sxe->xpath('//visitors/detail') as $item){ $row = simplexml_load_string($item->asXML()); $v = $row->xpath('//id[. ="'.$_COOKIE["judsons"].'"]'); } echo $v[0]; ?>\[/code\]This works great checks for an id against the id stored in the cookie. But based on that value being found how do I access the name and email for the key matched?Found & matched: 897987I want to echo the name and email to, so based on that is Mark McBob & [email protected]
 
Back
Top