简体   繁体   English

通过PHP Simple HTML Dom Parser排除元素

[英]Exclude elements through PHP Simple HTML Dom Parser

I would like to exclude some elements from DOM to extract a piece of text. 我想从DOM中排除一些元素以提取一段文本。

For example, with this code: 例如,使用以下代码:

<div>foo <b>bar</b></div>

I would like to extract only the text "foo". 我只想提取文本“ foo”。 Is there any way to do it? 有什么办法吗?

Thank you very much in advance. 提前非常感谢您。

PHP内置了函数strip_tags()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM