Skip to content

Commit 9616e42

Browse files
committed
update readme, examples
1 parent 077f6c1 commit 9616e42

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

examples/examples.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
var xml = require('../lib/xml');
22

3-
3+
console.log('===== Example 1 ====');
44
var example1 = { url: 'http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=opower' };
55
console.log(xml(example1));
66
//<url>http://www.google.com/search?aq=f&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=opower</url>
77

8+
console.log('\n===== Example 2 ====');
89
var example2 = [ { url: { _attr: { hostname: 'www.google.com', path: '/search?aq=f&sourceid=chrome&ie=UTF-8&q=opower' } } } ];
910
console.log(xml(example2));
1011
//<url hostname="www.google.com" path="/search?aq=f&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=opower"/>
1112

13+
console.log('\n===== Example 3 ====');
1214
var example3 = [ { toys: [ { toy: 'Transformers' } , { toy: 'GI Joe' }, { toy: 'He-man' } ] } ];
1315
console.log(xml(example3));
1416
//<toys><toy>Transformers</toy><toy>GI Joe</toy><toy>He-man</toy></toys>
15-
console.log(xml(example3, true));
17+
console.log(xml(example3, { indent: true }));
1618
/*
1719
<toys>
1820
<toy>Transformers</toy>
@@ -21,8 +23,9 @@ console.log(xml(example3, true));
2123
</toys>
2224
*/
2325

26+
console.log('\n===== Example 4 ====');
2427
var example4 = [ { toys: [ { _attr: { decade: '80s', locale: 'US'} }, { toy: 'Transformers' } , { toy: 'GI Joe' }, { toy: 'He-man' } ] } ];
25-
console.log(xml(example4, true));
28+
console.log(xml(example4, { indent: true }));
2629
/*
2730
<toys decade="80s" locale="US">
2831
<toy>Transformers</toy>
@@ -31,8 +34,9 @@ console.log(xml(example4, true));
3134
</toys>
3235
*/
3336

37+
console.log('\n===== Example 5 ====');
3438
var example5 = [ { toys: [ { _attr: { decade: '80s', locale: 'US'} }, { toy: 'Transformers' } , { toy: [ { _attr: { knowing: 'half the battle' } }, 'GI Joe'] }, { toy: [ { name: 'He-man' }, { description: { _cdata: '<strong>Master of the Universe!</strong>'} } ] } ] } ];
35-
console.log(xml(example5, true));
39+
console.log(xml(example5, { indent: true, declaration: true }));
3640
/*
3741
<toys><toy>Transformers</toy><toy>GI Joe</toy><toy>He-man</toy></toys>
3842
<toys>
@@ -57,8 +61,9 @@ console.log(xml(example5, true));
5761
</toys>
5862
*/
5963

64+
console.log('\n===== Example 6 ====');
6065
var elem = xml.Element({ _attr: { decade: '80s', locale: 'US'} });
61-
var xmlStream = xml({ toys: elem }, true);
66+
var xmlStream = xml({ toys: elem }, { indent: true } );
6267
xmlStream.on('data', function (chunk) {console.log("data:", chunk)});
6368
elem.push({ toy: 'Transformers' });
6469
elem.push({ toy: 'GI Joe' });

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xml",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples.",
55
"homepage": "http://github.com/dylang/node-xml",
66
"keywords": [
@@ -15,7 +15,8 @@
1515
"Dylan Greene (https://github.com/dylang)",
1616
"Dodo (https://github.com/dodo)",
1717
"Felix Geisendrfer ([email protected])",
18-
"Mithgol"
18+
"Mithgol",
19+
"carolineBda (https://github.com/carolineBda)"
1920
],
2021
"repository":
2122
{

readme.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ data: </toys>
8383
*/
8484
```
8585

86-
87-
`declartion` {_options_} Add default xml declaration as first node.
86+
`declartion` _optional_ Add default xml declaration as first node.
8887

8988
_options_ are:
9089
* encoding: 'value'

0 commit comments

Comments
 (0)