oozcitak/xmlbuilder-js


An XML builder for node.js

License: MIT

Language: CoffeeScript

Keywords: coffeescript, javascript, node-js, xml


xmlbuilder-js

An XML builder for node.js similar to java-xmlbuilder.

License NPM Version NPM Downloads

Travis Build Status AppVeyor Build status Dev Dependency Status Code Coverage

Installation:

npm install --save xmlbuilder

Usage:

var builder = require('xmlbuilder');

var xml = builder.create('root')
  .ele('xmlbuilder')
    .ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
  .end({ pretty: true});

console.log(xml);

will result in:

<?xml version="1.0"?>
<root>
  <xmlbuilder>
    <repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>
  </xmlbuilder>
</root>

It is also possible to convert objects into nodes:

var builder = require('xmlbuilder');

var obj = {
  root: {
    xmlbuilder: {
      repo: {
        '@type': 'git', // attributes start with @
        '#text': 'git://github.com/oozcitak/xmlbuilder-js.git' // text node
      }
    }
  }
};

var xml = builder.create(obj).end({ pretty: true});
console.log(xml);

If you need to do some processing:

var builder = require('xmlbuilder');

var root = builder.create('squares');
root.com('f(x) = x^2');
for(var i = 1; i <= 5; i++)
{
  var item = root.ele('data');
  item.att('x', i);
  item.att('y', i * i);
}

var xml = root.end({ pretty: true});
console.log(xml);

This will result in:

<?xml version="1.0"?>
<squares>
  <!-- f(x) = x^2 -->
  <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>

See the wiki for details and examples for more complex examples.

Project Statistics

Sourcerank 19
Repository Size 816 KB
Stars 744
Forks 90
Watchers 14
Open issues 4
Dependencies 6
Contributors 25
Tags 91
Created
Last updated
Last pushed

Top Contributors See all

Ozgur Ozcitak YUKI "Piro" Hiroshi btsimonh Nathan Shively-Sanders unclespike Yoji Shidara Benjamin Tan Rod Vagg Thierry Régagnon Brandon Mills Luan Muniz Julian Scheid Ivan Terpugov Rui Marinho ckaatz-here Nicholas Clawson Anna Henningsen ZeikJT Fabian Becker Tom Hughes

Packages Referencing this Repo

org.webjars.npm:github-com-oozcitak-xmlbuilder-js
WebJar for xmlbuilder
Latest release 4.1.0 - Published - 744 stars
Jolg42-xmlbuilder
An XML builder for node.js
Latest release 4.2.1 - Published - 744 stars
org.webjars.npm:xmlbuilder
WebJar for xmlbuilder
Latest release 10.0.0 - Updated - 744 stars
xmlbuilder
An XML builder for node.js
Latest release 13.0.2 - Updated - 744 stars

Recent Tags See all

v13.0.2 May 22, 2019
v13.0.1 May 10, 2019
v13.0.0 May 07, 2019
v12.0.1 April 30, 2019
v12.0.0 March 29, 2019
v11.0.1 March 22, 2019
v11.0.0 February 18, 2019
v10.1.1 October 24, 2018
v10.1.0 October 10, 2018
v10.0.0 April 26, 2018
v9.0.7 February 09, 2018
v9.0.7 February 09, 2018
v9.0.6 February 08, 2018
v9.0.6 February 08, 2018
v9.0.5 February 08, 2018

Interesting Forks See all

TooTallNate/xmlbuilder-js
An XML builder for node.js
CoffeeScript - Updated - 2 stars
coderguy/xmlbuilder-js
An XML builder for node.js
CoffeeScript - Last pushed - 2 stars
felixge/xmlbuilder-js
An XML builder for node.js
CoffeeScript - Last pushed - 2 stars
xdamman/xmlbuilder-js
An XML builder for node.js
CoffeeScript - Updated - 2 stars
unclespike/xmlbuilder-js
An XML builder for node.js
CoffeeScript - Last pushed - 2 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-05-22 06:45:04 UTC

Login to resync this repository