route/vendor/github.com/ailncode/gluaxmlpath
Cadey Ratio 18a2049013 cmd/construct: start work on eclier frontend 2018-01-21 20:28:06 -08:00
..
README.md cmd/construct: start work on eclier frontend 2018-01-21 20:28:06 -08:00
api.go cmd/construct: start work on eclier frontend 2018-01-21 20:28:06 -08:00
xmlpath.go cmd/construct: start work on eclier frontend 2018-01-21 20:28:06 -08:00
xmlpathtype.go cmd/construct: start work on eclier frontend 2018-01-21 20:28:06 -08:00

README.md

gluaxmlpath

gluaxmlpath provides an easy way to use xmlpath from within GopherLua.

Installation

go get github.com/ailncode/gluaxmlpath

Usage

package main

import (
	"github.com/ailncode/gluaxmlpath"
	"github.com/yuin/gopher-lua"
)

func main() {
	L := lua.NewState()
	defer L.Close()

	gluaxmlpath.Preload(L)

	if err := L.DoString(`
        xml ="<bookist><book>x1</book><book>x2</book><book>x3</book></booklist>"
        local xmlpath = require("xmlpath")
        node,err = xmlpath.loadxml(xml)
        path,err = xmlpath.compile("//book")
        it = path:iter(node)
        for k,v in pairs(it) do
            print(k,v:string())
        end
    `); err != nil {
		panic(err)
	}
}