Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 8, 2024 via pnpm

xmlbuilder 9.0.7

An XML builder for node.js
Package summary
Share
0
issues
1
license
1
MIT
Package created
28 Dec 2010
Version published
9 Feb 2018
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
xmlbuilder@9.0.7
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of xmlbuilder 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does xmlbuilder do?

XMLBuilder is a valuable resource for Node.js developers hoping to create XML data. Similar to java-xmlbuilder, this package lets you construct XML structures in a clear and organized manner. The successor xmlbuilder2 is even more powerful with full support for modern DOM specifications, XML namespaces, built-in converters for various formats, and additional features.

How do you use xmlbuilder?

To use XMLBuilder, start by installing it in your Node.js project using npm install xmlbuilder. Once the package is installed, require it at the start of your file with var builder = require('xmlbuilder');.

Now, you can build XML structures using .create, .ele and .end methods. Here's an example:

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);

In this example, we are creating a basic XML structure with a root element, a child element xmlbuilder and a nested child repo.

You can also convert JavaScript objects into XML structures:

var builder = require('xmlbuilder');

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

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

Here, the structure of the XML is defined by the structure of the JavaScript object.

If you need to do some processing, you can build your XML step by step:

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);

In this example, we're creating elements in a loop, and setting attributes on them using .att.

Where are the xmlbuilder docs?

The detailed documentation for XMLBuilder is available on the Github Wiki page. Here you'll find more information on usage, functions and additional examples to help you handle more complex scenarios. Exploring these documents is the best way to become proficient in XMLBuilder.