Skip to content

ls-age/xml

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@ls-age/xml

Modify XML documents in node.js with ease

CircleCI

An XML parsing, manipulation and serialization library. Implements some very basic DOM APIs (By far not complete).

Installation

As always, run npm install [--save] @ls-age/xml to install.

Usage

A basic example that parses an xml string, manipulates it and logs it's xml string again:

import { parse, build } from '@ls-age/xml';

parse(`<?xml version="1.0" ?>
<root>
  <content>content</content>
</root>`)
  .then(doc => {
    doc.documentElement.getElementsByTagName('content')[0].setAttribute('test', 'value');
    doc.documentElement.appendChild(doc.createElement('another'));
    
    console.log(build(doc, {
      indent: ' ',
      newline: '\r\n',
    }));
  });

/* Prints:
<?xml version="1.0" ?>\r\n
<root>\r\n
 <content test="value">content</content>\r\n
 <another />\r\n
</root>
*/

About

Modify XML documents in node.js with ease

Resources

Stars

Watchers

Forks

Packages

No packages published