开发者

php xml SimpleXMLElement

开发者 https://www.devze.com 2022-12-25 06:35 出处:网络
<Placemark id=\"p1\"></Placemark> <Placemark id=\"p2\"></Placemark> <Placemark id=\"p3\"></Placemark>
<Placemark id="p1"></Placemark>
<Placemark id="p2"></Placemark>
<Placemark id="p3"></Placemark>
<Placemark id="p4"></Pl开发者_如何转开发acemark>

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;

thanks


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

XPath is your friend :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消