从下一个标签获取文本 [英] Get text from next tag

查看:46
本文介绍了从下一个标签获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的 html 片段(当然被其他 html 包围):

I have a html snippet that looks like this (of course surrounded by other html):

<p class="finfot3"><b>Header:</b></p>
<p>Text</p>

我怎样才能从中获得Text?我正在使用 simple_html_dom,但如果 simple_html_dom 不能这样做,我可以使用其他东西.

How can I get Text from this? I'm using simple_html_dom, but I can use something else if simple_html_dom can't do this.

推荐答案

这是未经测试的,但您可能正在寻找 simple_html_doms next_sibling() 方法.

This is untested, but you might be looking for simple_html_doms next_sibling() method.

$html->find('p[class=finfot3]')->next_sibling()->innertext() 应该返回第二个

元素.

$html->find('p[class=finfot3]')->next_sibling()->innertext() should return the contents of the second <p> element.

这篇关于从下一个标签获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆