<Placemark id="p1"></Placemark>
<Placemark id="p2"></Placemark>
<Placemark id="p3"></Placemark>
<Placemark id="p4"></Placemark>
嗨,我在php中使用SimpleXMLElement, 我的问题是,我如何获得地标ID 3? 是这样的吗?
$page = utf8_encode(file_get_contents($request_url));
$xml = new SimpleXMLElement($page);
$xml->Response->Placemark['id=p3']->AddressDetails->Country->CountryName;
感谢
答案 0 :(得分:1)
$xml->xpath("Placemark[@id='p3']")->AddressDetails->Country->CountryName;
XPath是你的朋友: - )