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

elementtree

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elementtree - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.travis.yml

32

lib/elementtree.js

@@ -303,3 +303,3 @@ /**

else {
var qnames, namespaces;
var qnames, namespaces, indent, indent_string;
var x = _namespaces(this._root, options.encoding, options.default_namespace);

@@ -309,6 +309,14 @@ qnames = x[0];

if (options.hasOwnProperty('indent')) {
indent = 0;
indent_string = new Array(options.indent + 1).join(' ');
}
else {
indent = false;
}
if (options.method === "xml") {
_serialize_xml(function(data) {
sb.push(data);
}, this._root, options.encoding, qnames, namespaces);
}, this._root, options.encoding, qnames, namespaces, indent, indent_string);
}

@@ -459,3 +467,3 @@ else {

function _serialize_xml(write, elem, encoding, qnames, namespaces) {
function _serialize_xml(write, elem, encoding, qnames, namespaces, indent, indent_string) {
var tag = elem.tag;

@@ -466,2 +474,5 @@ var text = elem.text;

var newlines = indent || (indent === 0);
write(Array(indent + 1).join(indent_string));
if (tag === Comment) {

@@ -480,3 +491,3 @@ write(sprintf("<!--%s-->", _escape_cdata(text, encoding)));

elem.iter(function(e) {
_serialize_xml(write, e, encoding, qnames, null);
_serialize_xml(write, e, encoding, qnames, null, newlines ? indent + 1 : false, indent_string);
});

@@ -527,2 +538,6 @@ }

write(">");
if (!text && newlines) {
write("\n");
}
if (text) {

@@ -532,5 +547,8 @@ write(_escape_cdata(text, encoding));

elem._children.forEach(function(e) {
_serialize_xml(write, e, encoding, qnames, null);
_serialize_xml(write, e, encoding, qnames, null, newlines ? indent + 1 : false, indent_string);
});
if (!text && indent) {
write(Array(indent + 1).join(indent_string));
}
write("</" + tag + ">");

@@ -543,2 +561,6 @@ }

}
if (newlines) {
write("\n");
}
}

@@ -545,0 +567,0 @@

6

package.json

@@ -9,3 +9,3 @@ {

"description": "XML Serialization and Parsing module based on Python's ElementTree.",
"version": "0.1.1",
"version": "0.1.2",
"keywords": [ "xml", "sax", "parser", "seralization", "elementtree" ],

@@ -28,6 +28,6 @@ "homepage": "https://github.com/racker/node-elementtree",

"dependencies" : {
"sax": "0.2.3"
"sax": "0.3.5"
},
"devDependencies": {
"whiskey": "0.4.1"
"whiskey": "0.6.8"
},

@@ -34,0 +34,0 @@ "licenses": [

@@ -6,2 +6,7 @@ node-elementtree

Installation
====================
$ npm install elementtree
Using the library

@@ -14,10 +19,11 @@ ====================

License
Build status
====================
node-elementtree is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html).
[![Build Status](https://secure.travis-ci.org/racker/node-elementtree.png)](http://travis-ci.org/racker/node-elementtree)
Installation
License
====================
$ npm install elementtree
node-elementtree is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html).

@@ -128,2 +128,43 @@ /**

exports['test_write_with_options'] = function(test, assert) {
var i = 0;
var e = new Element('bar', {});
var expected1 = "<?xml version='1.0' encoding='utf-8'?>\n" +
'<bar>\n' +
' <blah a="11">\n' +
' <baz d="11">test</baz>\n' +
' </blah>\n' +
' <blah a="12" />\n' +
' <gag a="13" b="abc">ponies</gag>\n' +
'</bar>\n';
var expected2 = "<?xml version='1.0' encoding='utf-8'?>\n" +
'<bar>\n' +
' <blah a="11">\n' +
' <baz d="11">test</baz>\n' +
' </blah>\n' +
' <blah a="12" />\n' +
' <gag a="13" b="abc">ponies</gag>\n' +
'</bar>\n';
var se1 = SubElement(e, "blah", {a: 11});
var se2 = SubElement(se1, "baz", {d: 11});
se2.text = 'test';
SubElement(e, "blah", {a: 12});
var se = et.SubElement(e, "gag", {a: '13', b: 'abc'});
se.text = 'ponies';
se.itertext(function(text) {
assert.equal(text, 'ponies');
i++;
});
assert.equal(i, 1);
var etree = new ElementTree(e);
var xml1 = etree.write({'indent': 4});
var xml2 = etree.write({'indent': 2});
assert.equal(xml1, expected1);
assert.equal(xml2, expected2);
test.finish();
};
exports['test_parse_and_find_2'] = function(test, assert) {

@@ -130,0 +171,0 @@ var data = readFile('xml1.xml');

Sorry, the diff of this file is not supported yet

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