I’m trying to access the multiple items across multiple Xpath queries, while using the first query as a base.
I tried:
$playerinfo = $xpath->query('//*[@class="PlayerHeader"]');
$playername = $xpath->query('/h3/a', $playerinfo);
echo $playername->item(0)->nodeValue;
Nothing is returned. If I do
$playerinfo = $xpath->query('//*[@class="PlayerHeader"]/h3/a');
echo $playerinfo->item(0)->nodeValue;
It works fine. Any help is appreciated.
$playerinfo is a list of matching nodes – when you use it as the context for a subsequent search, the context can only be a SINGLE node, not a node list: