Package Exports
- xmlbuilder/lib/XMLBuilder
- xmlbuilder/lib/XMLFragment
- xmlbuilder/lib/index
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xmlbuilder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
xmlbuilder-js
An XMLBuilder for node.js similar to java-xmlbuilder.
Installation:
npm install xmlbuilderUsage:
var builder = require('xmlbuilder').builder();
builder.begin('root')
.ele('xmlbuilder')
.att('for', 'node-js')
.att('awesome', 'CoffeeScript')
.ele('repo')
.att('type', 'git')
.txt('git://github.com/oozcitak/xmlbuilder-js.git')
.up()
.up()
.up()
.ele('test')
.txt('complete');
console.log(builder.toString({ pretty: true });will result in:
<root>
<xmlbuilder for="node-js" awesome="CoffeeScript">
<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>
</xmlbuilder>
<test>complete</test>
</root>If you need to do some processing:
var root = builder.begin('squares');
for(var i = 1; i <= 5; i++)
{
var item = root.ele('data');
item.att('x', i);
item.att('y', i * i);
}This will result in:
<squares>
<data x="1" y="1"/>
<data x="2" y="4"/>
<data x="3" y="9"/>
<data x="4" y="16"/>
<data x="5" y="25"/>
</squares>