The class Jini
helps you build an XPATH.
require 'jini'
xpath = Jini.new
.add_node('parent') # addition a path node
.add_node('child') # addition a path node
.add_attr('key', 'value') # addition an attribute
.remove_node('child') # removes node
.to_s # convert it to a string
puts(xpath) # -> xpath: /parent[@key="value"]
The full list of methods is here.
Install it:
$ gem install jini
Or add this to your Gemfile
:
gem 'jini'
Pay attention, it is not a parser. The only functionality this gem provides is building XPATHs.
New features requests
If you find an error, or you want to add new functionality, just create a new Issue
and describe what happened, also try to add/fix something and send pull request.