A Lua XPath library based on libxml2.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build-aux
doc
m4
rockspec
src
tests
.gitignore
AUTHORS
COPYING
ChangeLog
INSTALL
Makefile.am
Makefile.in
NEWS
README
README.md
aclocal.m4
config.h.in
configure
configure.ac
libtool

README.md

lua-xpath

A Lua XPath library based on libxml2. It provides easy-to-use APIs inspired by Scrapy's selector classes.

Examples

local xpath = require("xpath")



-- load data from file
selector = xpath.loadfile(html)
-- load data from string
selector = xpath.loads("<html></html>")


------------------ OOP style ----------------------------

items = selector:xpath("//div[@name='shit']")

for k, v in ipairs(items) do
    print(v:extract())
end


------------------ general lua style --------------------

items = xpath.select(selector, "//div[@name='shit']")

for k, v in ipairs(items) do
    print(xpath.extract(v))
end

Installation

  • To install from source

      ./configure --libdir=/usr/local/lib/lua/5.1 --datadir=/usr/local/share/lua/5.1
      make
      make install
    
  • To install from source with luarocks

      luarocks build rockspec/lua-xpath-<version>.rockspec