0
Я ищу способ получить nodeValue внука. Я имею только однозначный доступ к классу «Я имею однозначный доступ к этому классу», как показано ниже. Как мне это сделать?получить внук nodeValue при использовании XPath
<class="I have unambiguous access to this class">
- <class="childClass">
-- <class="grandsonClass">
///////
function curlGet($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($url));
$results = curl_exec($ch);
curl_close($ch);
return $results;
}
function returnXPathObject($item){
$xmlPageDom = new DOMDocument();
@$xmlPageDom->loadHTML($item);
$xmlPageXPath = new DOMXPath($xmlPageDom);
return $xmlPageXPath;
}
$examplePage = curlGet("www.example.com");
$exampleXPath = returnXPathObject($examplePage);
$rating = $exampleXPath->query("//span[@class='grandfather']"); // I can access this guy, but I want it's grandchild.
// get child of grandfather's child (grandson of grandfather)