You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-32Lines changed: 15 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -40,31 +40,23 @@ Validate XML, Parse XML to JS/JSON and vise versa, or parse XML to Nimn rapidly
40
40
41
41
## How to use
42
42
43
-
**in NPM package**
43
+
To use it in **NPM package** install it first
44
44
45
-
install it first
45
+
`$npm install fast-xml-parser` or using [yarn](https://yarnpkg.com/)`$yarn add fast-xml-parser`
46
46
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.
56
48
57
49
`$npm install fast-xml-parser -g`
58
50
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)
62
52
63
-
### Usage
53
+
### XML to JSON or XML to Nimn
64
54
```js
65
55
var fastXmlParser =require('fast-xml-parser');
66
56
var jsonObj =fastXmlParser.parse(xmlData);
67
-
57
+
//construct schema manually or with the help of schema builder
58
+
var nimndata =fastXmlParser.parseToNimn(xmlData,schema);
var tObj =fastXmlParser.getTraversalObj(xmlData,options);
88
80
var jsonObj =fastXmlParser.convertToJson(tObj,options);
89
81
82
+
//construct schema manually or with the help of schema builder
83
+
var nimndata =fastXmlParser.convertTonimn(tObj,schema,options);
84
+
90
85
```
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
+
91
89
**OPTIONS** :
92
90
93
91
***attributeNamePrefix** : prepend given string to attribute name for identification
@@ -157,21 +155,6 @@ With the correct options, you can get the almost original XML without losing any
157
155
***indentBy** : indent by this char `when` format is set to `true`
158
156
***supressEmptyNode** : If set to `true`, tags with no value (text or nested tags) are written as self closing tags.
159
157
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
-
175
158
## Comparision
176
159
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.
0 commit comments