PHP XPath,无法在目标标记内的标记后检索文本


PHP XPath, cannot retrieve text after tags inside targeted tags

我有这个html代码,要对它进行xpath:

<b>Random Field:</b>
<p>
   A random field describes an <a href="/index.php?page=glossary&term_id=230">
   experiment</a> with outcomes being functions of more than one continuous variable, 
   for example U(x,y,z), where  x, y, and z are coordinates in space. Random field is 
   extension of the concept of <a href="/index.php?page=glossary&term_id=598">random 
   process</a> into the case of multivariate argument.
</p>

我试着在<p>标签中提取文本:

$dom = new DomDocument();
$dom->loadHtml($curl_scraped_page);
$xpath = new DomXPath($dom);
print $xpath->evaluate('string(//p[preceding::b]/text())');

但它给了我这个:

A random field describes an

我想要的是:

A random field describes an ..(an so on until).. of multivariate argument.所以我猜问题出在<a>标签上。因为每次我尝试在同一个图案化文档上执行此操作时,它都会在这个<a>标记之前停止。谢谢

这将起作用:

$xpath->query('//p[preceding::b]')->item(0)->textContent;

XPath中有一个string-join函数,但遗憾的是,PHP使用的lbxml中的XPath1.0版本中没有。