Permalink
Browse files

update readme, examples

  • Loading branch information...
1 parent 077f6c1 commit 9616e42d7022565718e2e69a206d0098503957eb @dylang committed Nov 8, 2013
Showing with 14 additions and 9 deletions.
  1. +10 −5 examples/examples.js
  2. +3 −2 package.json
  3. +1 −2 readme.md
View
@@ -1,18 +1,20 @@
var xml = require('../lib/xml');
-
+console.log('===== Example 1 ====');
var example1 = { url: 'http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=opower' };
console.log(xml(example1));
//<url>http://www.google.com/search?aq=f&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=opower</url>
+console.log('\n===== Example 2 ====');
var example2 = [ { url: { _attr: { hostname: 'www.google.com', path: '/search?aq=f&sourceid=chrome&ie=UTF-8&q=opower' } } } ];
console.log(xml(example2));
//<url hostname="www.google.com" path="/search?aq=f&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=opower"/>
+console.log('\n===== Example 3 ====');
var example3 = [ { toys: [ { toy: 'Transformers' } , { toy: 'GI Joe' }, { toy: 'He-man' } ] } ];
console.log(xml(example3));
//<toys><toy>Transformers</toy><toy>GI Joe</toy><toy>He-man</toy></toys>
-console.log(xml(example3, true));
+console.log(xml(example3, { indent: true }));
/*
<toys>
<toy>Transformers</toy>
@@ -21,8 +23,9 @@ console.log(xml(example3, true));
</toys>
*/
+console.log('\n===== Example 4 ====');
var example4 = [ { toys: [ { _attr: { decade: '80s', locale: 'US'} }, { toy: 'Transformers' } , { toy: 'GI Joe' }, { toy: 'He-man' } ] } ];
-console.log(xml(example4, true));
+console.log(xml(example4, { indent: true }));
/*
<toys decade="80s" locale="US">
<toy>Transformers</toy>
@@ -31,8 +34,9 @@ console.log(xml(example4, true));
</toys>
*/
+console.log('\n===== Example 5 ====');
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>'} } ] } ] } ];
-console.log(xml(example5, true));
+console.log(xml(example5, { indent: true, declaration: true }));
/*
<toys><toy>Transformers</toy><toy>GI Joe</toy><toy>He-man</toy></toys>
<toys>
@@ -57,8 +61,9 @@ console.log(xml(example5, true));
</toys>
*/
+console.log('\n===== Example 6 ====');
var elem = xml.Element({ _attr: { decade: '80s', locale: 'US'} });
-var xmlStream = xml({ toys: elem }, true);
+var xmlStream = xml({ toys: elem }, { indent: true } );
xmlStream.on('data', function (chunk) {console.log("data:", chunk)});
elem.push({ toy: 'Transformers' });
elem.push({ toy: 'GI Joe' });
View
@@ -1,6 +1,6 @@
{
"name": "xml",
- "version": "0.0.8",
+ "version": "0.0.9",
"description": "Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples.",
"homepage": "http://github.com/dylang/node-xml",
"keywords": [
@@ -15,7 +15,8 @@
"Dylan Greene (https://github.com/dylang)",
"Dodo (https://github.com/dodo)",
"Felix Geisendrfer (felix@debuggable.com)",
- "Mithgol"
+ "Mithgol",
+ "carolineBda (https://github.com/carolineBda)"
],
"repository":
{
View
@@ -83,8 +83,7 @@ data: </toys>
*/
```
-
-`declartion` {_options_} Add default xml declaration as first node.
+`declartion` _optional_ Add default xml declaration as first node.
_options_ are:
* encoding: 'value'

0 comments on commit 9616e42

Please sign in to comment.