Parsing the html doctype tag in nokigiri

How can I parse the doctype tag to get the html version from the html file?

Attempting to use doctype (either DOCTYPE or! DOCTYPE) as an argument in xpath raises an invalidide expression error.

+4
source share
1 answer

The document type is not part of the document, but is part of its 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 
+5
source

Source: https://habr.com/ru/post/1348015/


All Articles