Validating XML schema against DTD in Ruby
Ruby allows you to validate XML against DTD schema file with the help of nakogiri gem. This gem has validate method that allows you to parse DTD schema and then apply it against target XML
gem ‘nokogiri’
require ‘nokogiri’
dtd = Nokogiri::XML::Document.parse(%{YOUR_DTD_SCHEMA})
document = Nokogiri::XML(File.open(“xmlDoc.xml”))
document.external_subset.validate
Ruby’s gem such as Nokogiri relies on GNOM libxml2 library and it is simply a wrapper around this library providing all of the functionality from GNOM libxml2