- var_dump: documentation ( source)
<?php
$html = <<<EOF
<div id="nav">
<ul id="someID">
<li><a href="/poker/?ca=v"> THIS </a></li>
</ul>
</div>
EOF;
function extractNodeValue($query, $xPath, $attribute = null) {
$node = $xPath->query("//{$query}")->item(0);
if (!$node) {
return null;
}
return $attribute ? $node->getAttribute($attribute) : $node->nodeValue;
}
$document = new DOMDocument();
$document->loadHTML($html);
$xPath = new DOMXpath($document);
$name = extractNodeValue("//a[@href='/poker/?ca=v']/text()",$xPath);
var_dump($name);