# vtd-xml Parse large amounts of XML quickly and easily. **This library currently only works with JRuby.** ## Installation Add this line to your application's Gemfile: gem 'vtd-xml', '~> 0.0.1' And then execute: bundle Or install it yourself as: gem install vtd-xml ## Usage With the following example XML: ``` xml ``` ### Parsing a file ``` ruby require 'vtd-xml' # Create a parser parser = VTD::Xml::Parser.new 'path/to.xml' # This shortcut does the same parser = VTD::Xml.open 'path/to.xml' parser.find('//book/author').each do |node| # Iterates through each node end parser.find('//book/author').max_by { |node| node['sold'] } ``` ### Finding a node ``` ruby node = parser.find('//book/author[1]').first ``` ### Working with attributes ``` ruby # Accessing attributes node['name'] node.fetch('missing', 'so use this default') node.fetch('another-missing') { 'so call this block and use it' } node.slice('title', 'missing') # => {'title' => 'A Tale of Two Cities', 'missing' => nil} node.attributes # => returns every attribute ``` **See the examples directory for more.** ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request