Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xml2obj-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml2obj-stream - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

index.js

@@ -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 @@

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc