作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
如何解析 doctype 标签以从 html 文件中获取 html 版本?
尝试使用 doctype(或 DOCTYPE 或 !DOCTYPE)作为 xpath 中的参数会引发无效表达式错误。
最佳答案
doctype 不是文档的一部分,而是 DTD 的一部分
require 'rubygems'
require 'nokogiri'
html = <<EOF
<!DOCTYPE foo PUBLIC "bar" "qux">
<html>
</html>
EOF
doc = Nokogiri::HTML(html)
puts doc.internal_subset.name
puts doc.internal_subset.external_id
puts doc.internal_subset.system_id
关于ruby - 在 Nokogiri 中解析出 html doctype 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5657360/
我是一名优秀的程序员,十分优秀!