Socket
Socket
Sign inDemoInstall

pixl-xml

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.12 to 1.0.13

2

package.json
{
"name": "pixl-xml",
"version": "1.0.12",
"version": "1.0.13",
"description": "A simple module for parsing and composing XML.",

@@ -5,0 +5,0 @@ "author": "Joseph Huckaby <jhuckaby@gmail.com>",

@@ -196,2 +196,34 @@ # Overview

### forceArrays
By default single elements are not represented as arrays, until another element with the same appears at the same level in the XML tree. However, if you want to force every element into an array all the time, even when there is only a single element with a given name, set the `forceArrays` property to true. Example:
```js
var xml_string = '<?xml version="1.0"?><Document>' +
'<Simple>Hello</Simple>' +
'<Node Key="Value">Complex</Node>' +
'</Document>';
var doc = XML.parse( xml_string, { forceArrays: true } );
console.log( doc );
```
With the `forceArrays` flag set to true, this would produce the following object:
```js
{
"Simple": [
"Hello"
],
"Node": [
{
"Key": "Value",
"_Data": "Complex"
}
]
}
```
Please note that this feature applies only to elements, not attributes.
## Composing XML

@@ -198,0 +230,0 @@

@@ -81,2 +81,3 @@ /*

XML.prototype.lowerCase = false;
XML.prototype.forceArrays = false;

@@ -216,2 +217,5 @@ XML.prototype.patTag = /([^<]*?)<([^>]+)>/g;

}
else if (this.forceArrays && (branch != this.tree)) {
branch[nodeName] = [ leaf ];
}
else {

@@ -218,0 +222,0 @@ branch[nodeName] = leaf;

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc