Skip to content

Instantly share code, notes, and snippets.

@Fivell
Created December 16, 2016 11:24
Show Gist options
  • Save Fivell/3e66ea8cf38185ec5997ae2e9f90a716 to your computer and use it in GitHub Desktop.
Save Fivell/3e66ea8cf38185ec5997ae2e9f90a716 to your computer and use it in GitHub Desktop.
require 'rubygems'
gem 'nokogiri'
require 'nokogiri'
def validate(document_path, schema_path, root_element)
schema = Nokogiri::XML::Schema(File.read(schema_path))
document = Nokogiri::XML(File.read(document_path))
schema.validate(document.xpath("//#{root_element}").to_s)
end
validate('input.xml', 'schema.xdf', 'container').each do |error|
puts error.message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment