Permalink
Browse files

Shorter example

  • Loading branch information...
oozcitak committed Jul 10, 2012
1 parent 7faebd2 commit 409ed7091d95bc023b18ca0f9eb25a41f3590a8c
Showing with 2 additions and 21 deletions.
  1. +2 −21 README.md
View
@@ -23,15 +23,8 @@ var builder = require('xmlbuilder');
var doc = builder.create();
doc.begin('root', {'version': '1.0'})
- .ele('xmlbuilder')
- .att('for', 'node-js')
- .ele('repo')
- .att('type', 'git')
- .txt('git://github.com/oozcitak/xmlbuilder-js.git')
- .up()
- .up()
- .ele('test')
- .txt('complete');
+ .ele('xmlbuilder', {'for': 'node-js'})
+ .ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
console.log(doc.toString({ pretty: true }));
```
@@ -44,21 +37,9 @@ will result in:
<xmlbuilder for="node-js">
<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>
</xmlbuilder>
- <test>complete</test>
</root>
```
-You can specify attributes and text at element creation so you can write the above code as:
-
-``` js
-doc.begin('root', {'version': '1.0'})
- .ele('xmlbuilder', {'for': 'node-js'})
- .ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
- .up()
- .up()
- .ele('test', 'complete');
-```
-
If you need to do some processing:
``` js

0 comments on commit 409ed70

Please sign in to comment.