Comparing version 0.8.1 to 0.8.2
{ | ||
"name": "xml-js", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "A convertor between XML text and Javascript object / JSON text.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,4 +35,6 @@ ![Alt text](/logo.svg?raw=true "Logo") | ||
## Installation | ||
## Usage | ||
### Installation | ||
```bash | ||
@@ -42,6 +44,4 @@ npm install xml-js | ||
## Code Example | ||
### Quick start: | ||
Quick start: | ||
```js | ||
@@ -61,7 +61,2 @@ var convert = require('xml-js'); | ||
| result1 (compact) | result2 (non-compact) | | ||
|:------------------|:----------------------| | ||
| <code>{<br> "_declaration": {<br> "_attributes": {<br> "version": "1.0",<br> "encoding": "utf-8"<br> }<br> },<br> "note": {<br> "_attributes": {<br> "importance": "high",<br> "logged": "true"<br> },<br> "title": {<br> "_text": "Happy"<br> },<br> "todo": [<br> {<br> "_text": "Work"<br> },<br> {<br> "_text": "Play"<br> }<br> ]<br> }<br>}</code>|<code>{<br> "declaration": {<br> "attributes": {<br> "version": "1.0",<br> "encoding": "utf-8"<br> }<br> },<br> "elements": [<br> {<br> "type": "element",<br> "name": "note",<br> "attributes": {<br> "importance": "high",<br> "logged": "true"<br> },<br> "elements": [<br> {<br> "type": "element",<br> "name": "title",<br> "elements": [<br> {<br> "type": "text",<br> "text": "Happy"<br> }<br> ]<br> },<br> {<br> "type": "element",<br> "name": "todo",<br> "elements": [<br> {<br> "type": "text",<br> "text": "Work"<br> }<br> ]<br> },<br> {<br> "type": "element",<br> "name": "todo",<br> "elements": [<br> {<br> "type": "text",<br> "text": "Play"<br> }<br> ]<br> }<br> ]<br> }<br> ]<br>}</code>| | ||
## API Reference | ||
@@ -71,2 +66,4 @@ | ||
To convert JavaScript object to XML text, use `js2xml()`. To convert JSON text to XML text, use `json2xml()`. The below options are applicable to both functions. | ||
```js | ||
@@ -80,3 +77,3 @@ var convert = require('xml-js'); | ||
| Option | Default | Description | ||
| Option | Default | Description | | ||
|:----------------------|:--------|:------------| | ||
@@ -94,2 +91,4 @@ | `ignoreDeclaration` | `false` | Whether to ignore writing declaration directives of xml. For example, `<?xml?>` will be ignored. | | ||
To convert XML text to JavaScript object, use `xml2js()`. To convert XML text to JSON text, use `xml2json()`. The below options are applicable to both functions. | ||
```js | ||
@@ -103,3 +102,3 @@ var convert = require('xml-js'); | ||
| Option | Default | Description | ||
| Option | Default | Description | | ||
|:--------------------|:--------|:------------| | ||
@@ -119,5 +118,6 @@ | `ignoreDeclaration` | `false` | Whether to ignore writing declaration property. That is, no `declaration` property will be generated. | | ||
To change default key names in the output object, use the following options: | ||
| Option | Default | Description | ||
| Option | Default | Description | | ||
|:--------------------|:--------|:------------| | ||
| `declarationKey` | `"declaration"` or `"declaration"` | Name of the property key which will be used for the declaration. For example, if `declarationKey: '$declaration'` then output of `<?xml?>` will be `{"$declaration":{}}` *(in compact form)* | | ||
| `declarationKey` | `"declaration"` or `"_declaration"` | Name of the property key which will be used for the declaration. For example, if `declarationKey: '$declaration'` then output of `<?xml?>` will be `{"$declaration":{}}` *(in compact form)* | | ||
| `attributesKey` | `"attributes"` or `"_attributes"` | Name of the property key which will be used for the attributes. For example, if `attributesKey: '$attributes'` then output of `<a x="hello"/>` will be `{"a":{$attributes:{"x":"hello"}}}` *(in compact form)* | | ||
@@ -124,0 +124,0 @@ | `textKey` | `"text"` or `"_text"` | Name of the property key which will be used for the text. For example, if `textKey: '$text'` then output of `<a>hi</a>` will be `{"a":{"$text":"Hi"}}` *(in compact form)* | |
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
1347424