Skip to content

Commit af57ad1

Browse files
committed
Update read me
1 parent b3d583c commit af57ad1

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

README.md

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,23 @@ Validate XML, Parse XML to JS/JSON and vise versa, or parse XML to Nimn rapidly
4040

4141
## How to use
4242

43-
**in NPM package**
43+
To use it in **NPM package** install it first
4444

45-
install it first
45+
`$npm install fast-xml-parser` or using [yarn](https://yarnpkg.com/) `$yarn add fast-xml-parser`
4646

47-
`$npm install fast-xml-parser`
48-
49-
or using [yarn](https://yarnpkg.com/)
50-
51-
`$yarn add fast-xml-parser`
52-
53-
**From CLI**
54-
55-
Install it globally with `-g` option.
47+
To use it from **CLI** Install it globally with `-g` option.
5648

5749
`$npm install fast-xml-parser -g`
5850

59-
**on webpage**
60-
61-
Include it from [parser.js](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/lib/parser.js) Or directly from [CDN](https://cdnjs.com/libraries/fast-xml-parser)
51+
To use it on a**webpage** Include it from [parser.js](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/lib/parser.js) Or directly from [CDN](https://cdnjs.com/libraries/fast-xml-parser)
6252

63-
### Usage
53+
### XML to JSON or XML to Nimn
6454
```js
6555
var fastXmlParser = require('fast-xml-parser');
6656
var jsonObj = fastXmlParser.parse(xmlData);
67-
57+
//construct schema manually or with the help of schema builder
58+
var nimndata = fastXmlParser.parseToNimn(xmlData,schema);
59+
//or
6860
var options = {
6961
attributeNamePrefix : "@_",
7062
attrNodeName: "attr", //default is 'false'
@@ -87,7 +79,13 @@ if(fastXmlParser.validate(xmlData)=== true){//optional
8779
var tObj = fastXmlParser.getTraversalObj(xmlData,options);
8880
var jsonObj = fastXmlParser.convertToJson(tObj,options);
8981

82+
//construct schema manually or with the help of schema builder
83+
var nimndata = fastXmlParser.convertTonimn(tObj,schema,options);
84+
9085
```
86+
* NIMN (निम्न) data is the schema aware compressed form of data. It reduces JSON up to 50% or more of original data by removing field information. Check [specification](https://github.com/nimndata/spec) for more detail.
87+
* Check [nimnjs](https://github.com/nimndata/nimnjs-node) to know more about schema, json to nimndata and reverse transformation.
88+
9189
**OPTIONS** :
9290

9391
* **attributeNamePrefix** : prepend given string to attribute name for identification
@@ -122,7 +120,7 @@ if(result !== true) cnosole.log(result.err);
122120
var jsonObj = parser.parse(xmlData);
123121
```
124122

125-
### JSON or JS Object to XML
123+
### JSON / JS Object to XML
126124

127125
```js
128126
var Parser = require("fast-xml-parser").j2xParser;
@@ -157,21 +155,6 @@ With the correct options, you can get the almost original XML without losing any
157155
* **indentBy** : indent by this char `when` format is set to `true`
158156
* **supressEmptyNode** : If set to `true`, tags with no value (text or nested tags) are written as self closing tags.
159157

160-
### XML to Nimn
161-
NIMN (निम्न) data is the schema aware compressed form of data. It reduces JSON up to 50% or more of original data by removing field information. Check [specification](https://github.com/nimndata/spec) for more detail.
162-
163-
```js
164-
var fastXmlParser = require('fast-xml-parser');
165-
//set the options same for xml to json
166-
var tObj = fastXmlParser.getTraversalObj(xmlData,options);
167-
168-
var jsondata = fastXmlParser.convertToJson(tObj,options);
169-
170-
var nimndata = fastXmlParser.convertTonimn(tObj,schema,options);
171-
```
172-
* check [nimnjs](https://github.com/nimndata/nimnjs-node) to know more about schema, json to nimndata and reverse transformation.
173-
174-
175158
## Comparision
176159
We've copared various libraries which transforms XML to JS. Most of them either are dependent on C/C++ libraries, or slow, or don't do reverse transformation.
177160

0 commit comments

Comments
 (0)