Skip to content

Instantly share code, notes, and snippets.

@jnv
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnv/11763399bcfcead72a2c to your computer and use it in GitHub Desktop.
Save jnv/11763399bcfcead72a2c to your computer and use it in GitHub Desktop.
require 'multi_xml'
require 'pp'
xml = <<-EOF
<atom:feed xmlns="http://kosapi.feld.cvut.cz/schema/3" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:osearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:base="https://kosapi.fit.cvut.cz/api/3" xml:lang="cs">
<atom:link atom:rel="next" href="courses?offset=10&amp;limit=10"/>
<osearch:startIndex>0</osearch:startIndex>
</atom:feed>
EOF
[:rexml, :nokogiri, :libxml, :ox].each do |impl|
puts "#### #{impl}"
MultiXml.parser = impl
pp MultiXml.parse(xml)
end
#### rexml
{"feed"=>
{"xmlns"=>"http://kosapi.feld.cvut.cz/schema/3",
"xmlns:atom"=>"http://www.w3.org/2005/Atom",
"xmlns:osearch"=>"http://a9.com/-/spec/opensearch/1.1/",
"xmlns:xlink"=>"http://www.w3.org/1999/xlink",
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
"xml:base"=>"https://kosapi.fit.cvut.cz/api/3",
"xml:lang"=>"cs",
"link"=>{"atom:rel"=>"next", "href"=>"courses?offset=10&limit=10"},
"startIndex"=>"0"}}
#### nokogiri
{"feed"=>
{"link"=>{"rel"=>"next", "href"=>"courses?offset=10&limit=10"},
"startIndex"=>"0",
"base"=>"https://kosapi.fit.cvut.cz/api/3",
"lang"=>"cs"}}
#### libxml
{"feed"=>
{"link"=>{"rel"=>"next", "href"=>"courses?offset=10&limit=10"},
"startIndex"=>"0",
"base"=>"https://kosapi.fit.cvut.cz/api/3",
"lang"=>"cs"}}
#### ox
{"atom:feed"=>
{"xmlns"=>"http://kosapi.feld.cvut.cz/schema/3",
"xmlns:atom"=>"http://www.w3.org/2005/Atom",
"xmlns:osearch"=>"http://a9.com/-/spec/opensearch/1.1/",
"xmlns:xlink"=>"http://www.w3.org/1999/xlink",
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
"xml:base"=>"https://kosapi.fit.cvut.cz/api/3",
"xml:lang"=>"cs",
"atom:link"=>{"atom:rel"=>"next", "href"=>"courses?offset=10&limit=10"},
"osearch:startIndex"=>"0"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment