php xml SimpleXMLElement

1 Cevap php
<Placemark id="p1"></Placemark>
<Placemark id="p2"></Placemark>
<Placemark id="p3"></Placemark>
<Placemark id="p4"></Placemark>

hi,im using SimpleXMLElement in my php, my question is,how do i get placemark id 3? is that something like this ?

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

teşekkürler

1 Cevap

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

XPath arkadaşınız olduğunu :-)