Skip to content

Instantly share code, notes, and snippets.

@oogali
Created October 20, 2012 15:16
Show Gist options
  • Select an option

  • Save oogali/3923541 to your computer and use it in GitHub Desktop.

Select an option

Save oogali/3923541 to your computer and use it in GitHub Desktop.
testing xsi:type with ruby 1.8 xml parser
#!/usr/bin/env ruby
require 'rubygems'
require 'crack'
xmldoc = <<-doc
<root-node>
<child-node xsi:type = "mytypecast">data</child-node>
</root-node>
doc
c = Crack::XML.parse xmldoc
p c.to_hash
__END__
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:389:in `pull': Undefined prefix xsi found (REXML::UndefinedNamespaceException)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/set.rb:195:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/set.rb:195:in `each_key'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/set.rb:195:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:387:in `pull'
from /Library/Ruby/Gems/1.8/gems/crack-0.3.1/lib/crack/xml.rb:198:in `parse'
from /Library/Ruby/Gems/1.8/gems/crack-0.3.1/lib/crack/xml.rb:229:in `parse'
from test-xsi-type.rb:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment