Project

xpather

0.01
No commit activity in last 3 years
No release in over 3 years
Quick and painless XPath searching for Ruby using libxml2
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 12.3.3
 Project Readme

XPather Build Status

XPather is a small Ruby wrapper for doing fast xpath searching with libxml. It doesn't go incredibly deep but offers a simple and effective api.

Installation

$ gem install xpather

Usage

XML = File.read("/test/books.xml")
document = XPather.new(XML)
=> #<XPather:0x007f9bd2a32030>

document.get("/bookstore/book[1]/author")
=> "Giada De Laurentiis"

document.get("/bookstore/book/author")
=> ["Giada De Laurentiis", "J K. Rowling", "James McGovern", "Per Bothner", "Kurt Cagle", "James Linn", "Vaidyanathan Nagarajan", "Erik T. Ray"]

document.search("/bookstore/book[1]/author")
=> ["<author>Giada De Laurentiis</author>"]

document.search("/bookstore/book/author")
=> ["<author>Giada De Laurentiis</author>", "<author>J K. Rowling</author>", "<author>James McGovern</author>", "<author>Per Bothner</author>", "<author>Kurt Cagle</author>", "<author>James Linn</author>", "<author>Vaidyanathan Nagarajan</author>", "<author>Erik T. Ray</author>"]