2010-03-30 8 views
0
<Placemark id="p1"></Placemark> 
<Placemark id="p2"></Placemark> 
<Placemark id="p3"></Placemark> 
<Placemark id="p4"></Placemark> 

Salut, im en utilisant SimpleXMLElement dans mon php, ma question est, comment puis-je obtenir id 3 placemark? est-ce quelque chose comme ça?php xml SimpleXMLElement

$page = utf8_encode(file_get_contents($request_url)); 
$xml = new SimpleXMLElement($page); 
$xml->Response->Placemark['id=p3']->AddressDetails->Country->CountryName; 

grâce

+1

vous avez id = 3 dans votre code PHP, mais id = "p3" dans votre XML. Je ne sais pas si cela vous cause des problèmes. – easement

Répondre

1
$xml->xpath("Placemark[@id='p3']")->AddressDetails->Country->CountryName; 

XPath est votre ami :-)