我很难理解RegEx,而XPath似乎让我感到困惑。
属于$htmlsrc
的Html:
<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)
}