【问题标题】:XPath expression to get a string after a <br> tagXPath 表达式在 <br> 标记后获取字符串
【发布时间】:2019-06-11 17:57:22
【问题描述】:

我正在尝试获取article/div/p 中的内容,但只获取&lt;br&gt; 标记之后的日期。那是怎么做的?

<article>
    <h2>Man rescued after falling into Crater Lake</h2>
    <p class="summary highlight">
        Man rescued after falling 800 feet into Crater Lake in Oregon
    </p>

    <div class="body">
       <p>by Joe Sutton<br>
            June 11, 2019
        </p>
    </div>
</article>
$expression = "article/div/p";

【问题讨论】:

    标签: php xml xpath domxpath


    【解决方案1】:

    这个 XPath,

    //br/following-sibling::text()
    

    将选择br之后的所有后续兄弟文本节点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-04
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2011-02-12
      • 2013-03-12
      • 1970-01-01
      相关资源
      最近更新 更多