ruby - Validating DTD-String with Nokogiri -
i switching libxml nokogiri. have method in code check if xml document matches dtd. dtd read database (as string).
this example within irb session
require 'xml' doc = libxml::xml::document.string('<foo bar="baz" />') #=> <?xml version="1.0" encoding="utf-8"?> dtd = libxml::xml::dtd.new('<!element foo empty><!attlist foo bar id #required>') #=> #<libxml::xml::dtd:0x000000026f53b8> doc.validate dtd #=> true
as understand #validate
of nokogiri::xml::document
possible check dtds within document. how archive same result?
i think need internal_subset
:
require 'nokogiri' doc = nokogiri::html("<!doctype html>") # can info want doc.internal_subset # nokogiri::xml::dtd # example can name, system_id, external_id, etc doc.internal_subset.name doc.internal_subset.system_id doc.internal_subset.external_id
here full doc of nokogiri::xml::dtd.
thanks
Comments
Post a Comment