我很难理解 RegEx,而 XPath 似乎也让我感到困惑。
属于的Html $htmlsrc
:
<div class="text" style="font-family:monospace;">
<ol>
<li style="font-weight: normal; vertical-align:top;">
<div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">
sQrNWk8+aiRtcn/gFM9ptAf8m3NcRf4av4m76rUZeAA=
</div>
</li>
</ol>
</div>
正在查询字符串的 PHP:
$dom = new DOMDocument();
$dom->loadHTML($htmlsrc);
$xpath = new DOMXPath($dom);
$tags = $xpath->query('//div/ol/li/div');
var_dump($tags);
我真的很想返回sQrNWk8+aiRtcn/gFM9ptAf8m3NcRf4av4m76rUZeAA=
但是var_dump($tags)
只是显示一个空对象:
object(DOMNodeList)#24 (1) {
["length"]=>
int(1)
}