【发布时间】:2015-02-16 09:24:28
【问题描述】:
我有一些 html 代码,我会对其进行解析、修改。但是在我使用doc.to_html之后
nokogiri 将其转换回 html,但还附加了一些额外的标签,例如 doctype, html, head, body。有没有办法跳过这些标签,或者我应该手动删除它们?
【问题讨论】:
-
使用
DocumentFragment而不是Document:: stackoverflow.com/a/4907450/2035262 -
@mudasobwa,把它放到答案中,我接受它。这就是我一直在寻找的
-
还有其他一些方法。你能举个例子吗?你在节点上申请
#to_html吗?
标签: ruby-on-rails ruby nokogiri