从节点中删除元素
给定一个 Nokogiri::XML::Node 对象,如何删除它的一些 dom 节点?例如,假设我有一个 innerHtml
的对象:
hello world <b>this is in bold face</b> <div>this is inside a div</div> bye bye
如何删除
元素并获取 Nokogiri::XML::Node< /code> 对象,其 innerHtml
为:
hello world <b>this is in bold face</b> bye bye
Given a Nokogiri::XML::Node
object, how can I remove some of its dom nodes? For example, suppose I have an object whose innerHtml
is:
hello world <b>this is in bold face</b> <div>this is inside a div</div> bye bye
How can I remove the <div>
element and get a Nokogiri::XML::Node
object whose innerHtml
is:
hello world <b>this is in bold face</b> bye bye
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到
并对其调用
remove
。例如:Find the
<div>
and callremove
on it. For example: