Created
December 16, 2016 11:24
-
-
Save Fivell/3e66ea8cf38185ec5997ae2e9f90a716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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