00001 # xmlbuilder-js
00002
00003 An XML builder for [node.js](https:
00004 [java-xmlbuilder](https:
00005
00006 [;
00025 var xml = builder.create('root')
00026 .ele('xmlbuilder')
00027 .ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
00028 .end({ pretty: true});
00029
00030 console.log(xml);
00031 ```
00032
00033 will result in:
00034
00035 ``` xml
00036 <?xml version="1.0"?>
00037 <root>
00038 <xmlbuilder>
00039 <repo type="git">git:
00040 </xmlbuilder>
00041 </root>
00042 ```
00043
00044 It is also possible to convert objects into nodes:
00045
00046 ``` js
00047 builder.create({
00048 root: {
00049 xmlbuilder: {
00050 repo: {
00051 '@type': 'git',
00052 '#text': 'git://github.com/oozcitak/xmlbuilder-js.git'
00053 }
00054 }
00055 }
00056 });
00057 ```
00058
00059 If you need to do some processing:
00060
00061 ``` js
00062 var root = builder.create('squares');
00063 root.com('f(x) = x^2');
00064 for(var i = 1; i <= 5; i++)
00065 {
00066 var item = root.ele('data');
00067 item.att('x', i);
00068 item.att('y', i * i);
00069 }
00070 ```
00071
00072 This will result in:
00073
00074 ``` xml
00075 <?xml version="1.0"?>
00076 <squares>
00077 <!-- f(x) = x^2 -->
00078 <data x="1" y="1"/>
00079 <data x="2" y="4"/>
00080 <data x="3" y="9"/>
00081 <data x="4" y="16"/>
00082 <data x="5" y="25"/>
00083 </squares>
00084 ```
00085
00086 See the [wiki](https: