PHP SimpleXMLElement XPath Selection

Dzhax

New Member
I have the following XML: http://pastebin.com/QiRK72BKwhich is generated in response to a REST query. My code is very simple:\[code\]$xml = simplexml_load_file($url);var_dump($xml->getName());var_dump($xml->xpath("serverDetail/apiEnv"));\[/code\]in an attempted test case. The first var_dump reveals that the XML file is indeed being loaded:\[code\] string(21) "GeneralSearchResponse"\[/code\]However, the second var_dump puzzles me. I feel it should definitely match some data, but instead I get\[code\]array(0) { }\[/code\]I've also tried the xpath "/serverDetail/apiEnv" "//apiEnv" and "/" and always get an empty array. Am I misunderstanding xpath or perhaps missing some initialization step?
 
Back
Top