Skip to content

A simple XPath library to help stay sane while working with XML in Lua

Notifications You must be signed in to change notification settings

bkersten/lua-xpath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

lua-xpath is a simple XPath library to help stay sane while working with XML in Lua

Dependencies
------------------
LuaExpat and Lua Object Model (http:https://matthewwild.co.uk/projects/luaexpat/index.html)

Usage
--------

local lom = require "lxp.lom"
local xpath = require "xpath"

local xml = [[
<root>
    <node foo="bar">sample text</node>
    <node>other text</node>
</root>
]]

local xml_tree = lom.parse(xml)

local nodes = xpath.selectNodes(xml_tree, '/root/node[@foo="bar"]/text()')
for _,val in ipairs(nodes) do
    print(val)
end

The output will be "sample text"

About

A simple XPath library to help stay sane while working with XML in Lua

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages