1.0.6 • Published 7 years ago

libxmljs-lazy-builder v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

libxmljs-lazy-builder

Builds XML documents in a lazy way.

SYNOPSIS

const E = require('libxmljs-lazy-builder')

const doc = new E.libxml.Document()
const elem = E("root", {},
             E("kit", {color: "brown"}),
             "mars",
             E("kat"))(doc)

elem.toString()
   // => '<root><kit color="brown"/>mars<kat/></root>'

INSTALLATION

npm install libxmljs-lazy-builder --save

DESCRIPTION

API

E (name, {attrName: value, ...}, children, ...)

(You can name it arbitrarily.) This function generates a function which takes a libxml.Document object and returns a libxml.Element object.

A child can be a string or an another E() element. You can specify zero or more children.

Please note that you need to call the returned value from E() with a Document object to get an actual Element object. So, the whole structure should be something like:

const doc = new E.libxml.Document()
const elem = E("x", {}, E("y", {}, ...), ...)(doc)

E.libxml

The libxml module used internally in E. Use this to create a Document object.

Examples

Please see the test script in the repository.

DEPENDS ON

libxmljs

LICENSE

MIT

AUTHOR

Toru Hisai @torus

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago