Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit df70a01

Browse files
committed
Merge pull request #101 from robincsamuel/patch-1
Update README.md
2 parents 390e9cc + 4d5246c commit df70a01

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@ $ npm install xml2json
2222
```javascript
2323
var parser = require('xml2json');
2424

25+
// xml to json
2526
var xml = "<foo>bar</foo>";
2627
var json = parser.toJson(xml); //returns a string containing the JSON structure by default
2728
console.log(json);
29+
30+
// json to xml
31+
var json = {
32+
root: {
33+
name: {'$t': 'John', id:'idx'} // $t for text, and all others will be attributes
34+
}
35+
};
36+
var xml = parser.toXml(xml); //returns xml <root><name for="idx">John</name></root>
37+
console.log(xml)
38+
2839
```
2940
## API
3041

0 commit comments

Comments
 (0)