Skip to content

Commit 0d71785

Browse files
Merge pull request #562 from Omega-Ariston/addDocExample
complete README example usage
2 parents 8fc5b92 + a44bad4 commit 0d71785

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ var obj = {name: "Super", Surname: "Man", age: 23};
180180
var builder = new xml2js.Builder();
181181
var xml = builder.buildObject(obj);
182182
```
183+
will result in:
184+
185+
```xml
186+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
187+
<root>
188+
<name>Super</name>
189+
<Surname>Man</Surname>
190+
<age>23</age>
191+
</root>
192+
```
183193

184194
At the moment, a one to one bi-directional conversion is guaranteed only for
185195
default configuration, except for `attrkey`, `charkey` and `explicitArray` options
@@ -195,6 +205,11 @@ var obj = {root: {$: {id: "my id"}, _: "my inner text"}};
195205
var builder = new xml2js.Builder();
196206
var xml = builder.buildObject(obj);
197207
```
208+
will result in:
209+
```xml
210+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
211+
<root id="my id">my inner text</root>
212+
```
198213

199214
### Adding xmlns attributes
200215

0 commit comments

Comments
 (0)