Skip to content

Instantly share code, notes, and snippets.

@timrauhut
Created May 10, 2011 14:15
Show Gist options
  • Save timrauhut/964547 to your computer and use it in GitHub Desktop.
Save timrauhut/964547 to your computer and use it in GitHub Desktop.
Simple nokogiri xsd validator
require 'rubygems'
require 'nokogiri'
def validate(document_path, schema_path)
schema = Nokogiri::XML::Schema(File.read(schema_path))
document = Nokogiri::XML(File.read(document_path))
schema.validate(document)
end
validate('document.xml', 'schema.xsd').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