xml2obj-stream
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,6 @@ var expat = require('node-expat'); | ||
function Parser (readStream, options) { | ||
if (!(this instanceof Parser)) { | ||
return new Parser(readStream, options); | ||
} | ||
var self = this; | ||
@@ -7,0 +11,0 @@ |
{ | ||
"name": "xml2obj-stream", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "(XML -> JavaScript Object) low memory streaming parser based on node-expat C bindings", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# xml2obj-stream | ||
[![build status](http://img.shields.io/travis/voronianski/xml2obj-stream.svg?style=flat)](https://travis-ci.org/voronianski/xml2obj-stream) | ||
[![npm version](http://img.shields.io/npm/v/xml2obj-stream.svg?style=flat)](https://www.npmjs.org/package/xml2obj-stream) | ||
@@ -23,3 +24,3 @@ > Interface to iterate through XML resources and map them into JavaScript objects (allows custom transformations). | ||
- `trim` - remove leading and trailing whitespaces as well as line terminators in attributes and element values, default `true` | ||
- `sanitize` - sanitizes the such characters as `<, >, (, ), #, &, ", '` present in element values, default `false` | ||
- `sanitize` - sanitizes such characters as `<, >, (, ), #, &, ", '` present in element values, default `false` | ||
@@ -32,3 +33,3 @@ ### `each('element', iterator)` | ||
- each `<tag>` becomes **1 object** (including it's children, their attributes etc.) | ||
- each `<tag>` becomes **1 object** (including it's children, their attributes etc.), e.g. `<tag><child><id>12345</id><name>foo</name></child></tag>` turns to `{id: 12345, name: 'foo'}` | ||
- element's attributes like `<tag foo="bar">text</tag>` become properties of the object prefixed with element's name - `{'tag': 'text', 'tag-foo': 'bar'}` | ||
@@ -62,3 +63,4 @@ | ||
$name: 'column', | ||
$parent: null, | ||
// array of children objects if they are present | ||
@@ -124,11 +126,13 @@ $children: [{ | ||
console.dir(results); | ||
// outputs -> | ||
// [ | ||
// { name: 'dodo', value: 'bird', 'value-type': 'string' }, | ||
// { name: 'mighty', value: 'boosh', 'value-type': 'string' }, | ||
// { name: 'crack', value: 'fox', 'value-type': 'string' }, | ||
// { name: 'foo', value: true, 'value-type': 'boolean' }, | ||
// { name: 'uid', value: 12345, 'value-type': 'number' } | ||
// ] | ||
parseStream.on('end', function () { | ||
console.dir(results); | ||
// outputs -> | ||
// [ | ||
// { name: 'dodo', value: 'bird', 'value-type': 'string' }, | ||
// { name: 'mighty', value: 'boosh', 'value-type': 'string' }, | ||
// { name: 'crack', value: 'fox', 'value-type': 'string' }, | ||
// { name: 'foo', value: true, 'value-type': 'boolean' }, | ||
// { name: 'uid', value: 12345, 'value-type': 'number' } | ||
// ] | ||
}); | ||
``` | ||
@@ -181,9 +185,11 @@ | ||
console.dir(results); | ||
// outputs -> | ||
// [{ | ||
// 'act-id': 'H38310', | ||
// 'update-date-time': '20130628T11:24', | ||
// 'for-search': '20130628T11:22:19' | ||
// }] | ||
parseStream.on('end', function () { | ||
console.dir(results); | ||
// outputs -> | ||
// [{ | ||
// 'act-id': 'H38310', | ||
// 'update-date-time': '20130628T11:24', | ||
// 'for-search': '20130628T11:22:19' | ||
// }] | ||
}); | ||
``` | ||
@@ -190,0 +196,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18088
247
217