Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Lightweight XML parser for really big files
JavaScript
Branch: master

This branch is 3 commits ahead, 4 commits behind jahewson:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
LICENSE
README.md
package.json

README.md

xml2obj -- 基于node-xml

Same usage with big-xml

Install

npm install xml2obj

Example

XML files are streamed, and parsed one record at a time, which keeps memory usage low.

You must specify which XML elements should be considered as the root of a record, using a regex. In this example the elements Foo and Bar will be emitted as records.

var xml = require('xml2obj');

var reader = xml.createReader('data.xml.gz', /^(Foo|Bar)$/, { gzip: true });

reader.on('record', function(record) {
  console.log(record);
});

The output would take the form:

{ tag: 'Foo',
  attrs: { Name: 'John', Status: 'Student' },
  children: [
    { tag: 'Color', text: 'blue'} 
  ]
}
Something went wrong with that request. Please try again.