• Stars
    star
    916
  • Rank 47,899 (Top 1.0 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An XML builder for node.js

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

Announcing xmlbuilder2:

The new release of xmlbuilder is available at xmlbuilder2! xmlbuilder2 has been redesigned from the ground up to be fully conforming to the modern DOM specification. It supports XML namespaces, provides built-in converters for multiple formats, collection functions, and more. Please see upgrading from xmlbuilder in the wiki.

New development will be focused towards xmlbuilder2; xmlbuilder will only receive critical bug fixes.

Installation:

npm install 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>

Documentation:

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

Donations:

Please consider becoming a backer or sponsor to help support development.

Donate Button

More Repositories

1

xmlbuilder2

An XML builder for node.js
TypeScript
346
star
2

imagelistview

A .NET listview control for image files with asynchronously loaded thumbnails.
C#
163
star
3

exiflibrary

A .Net Standard library for editing Exif metadata
C#
115
star
4

SimpleCad

A basic CAD-like control surface for winforms.
C#
98
star
5

akismet-js

Akismet API client for node.js
TypeScript
31
star
6

TabControl

A winforms control with multiple tabs.
C#
27
star
7

WizardControl

Wizard control for winforms
C#
13
star
8

PagedControl

A winforms control with multiple pages.
C#
13
star
9

dom

A modern DOM implementation
TypeScript
11
star
10

eve-corp-portal

A custom CMS for corporations in the game Eve Online
PHP
8
star
11

TriMesh

A delaunay mesh generator.
C#
6
star
12

FileSystemControls

Various shell controls for winforms.
C#
5
star
13

canphotoblog

A dead easy photo blogging application powered by node.js
CoffeeScript
5
star
14

uts46

A Javascript implementation of Unicode IDNA Compatibility Processing (UTS 46)
TypeScript
4
star
15

meshgenerator

Automatically exported from code.google.com/p/meshgenerator
C#
4
star
16

SapCleaner

Batch deletes Sap2000 analysis files
C#
3
star
17

url

An implementation of the URL Living Standard
TypeScript
2
star
18

glcanvas

OpenGL Canvas Control for .Net
C++
2
star
19

infra

An implementation of the Infra Living Standard
TypeScript
2
star
20

util

Utility functions
TypeScript
2
star
21

xmlbuilder-typing-tests

Repository for testing TypeScript API of xmlbuilder.
TypeScript
1
star
22

oozcitak

1
star
23

perf

Performance testing for node.js
JavaScript
1
star
24

dotfiles

The contents of my dotfiles
Vim Script
1
star