An XML builder for \href{https://nodejs.org/}{\texttt{ node.\+js}} similar to \href{https://github.com/jmurty/java-xmlbuilder}{\texttt{ java-\/xmlbuilder}}.

\href{http://opensource.org/licenses/MIT}{\texttt{ }} \href{https://npmjs.com/package/xmlbuilder}{\texttt{ }} \href{https://npmjs.com/package/xmlbuilder}{\texttt{ }}

\href{http://travis-ci.org/oozcitak/xmlbuilder-js}{\texttt{ }} \href{https://ci.appveyor.com/project/oozcitak/xmlbuilder-js}{\texttt{ }} \href{https://david-dm.org/oozcitak/xmlbuilder-js}{\texttt{ }} \href{https://coveralls.io/github/oozcitak/xmlbuilder-js}{\texttt{ }}\hypertarget{md_sfcode_node_modules_xmlbuilder_README_autotoc_md34356}{}\doxysubsection{Installation\+:}\label{md_sfcode_node_modules_xmlbuilder_README_autotoc_md34356}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install xmlbuilder }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_xmlbuilder_README_autotoc_md34357}{}\doxysubsection{Usage\+:}\label{md_sfcode_node_modules_xmlbuilder_README_autotoc_md34357}

\begin{DoxyCode}{0}
\DoxyCodeLine{var builder = require('xmlbuilder');}
\DoxyCodeLine{var xml = builder.create('root')}
\DoxyCodeLine{  .ele('xmlbuilder')}
\DoxyCodeLine{    .ele('repo', \{'type': 'git'\}, 'git://github.com/oozcitak/xmlbuilder-\/js.git')}
\DoxyCodeLine{  .end(\{ pretty: true\});}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(xml); }

\end{DoxyCode}


will result in\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<?xml version="{}1.0"{}?>}
\DoxyCodeLine{<root>}
\DoxyCodeLine{  <xmlbuilder>}
\DoxyCodeLine{    <repo type="{}git"{}>git://github.com/oozcitak/xmlbuilder-\/js.git</repo>}
\DoxyCodeLine{  </xmlbuilder>}
\DoxyCodeLine{</root> }

\end{DoxyCode}


It is also possible to convert objects into nodes\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{builder.create(\{}
\DoxyCodeLine{  root: \{}
\DoxyCodeLine{    xmlbuilder: \{}
\DoxyCodeLine{      repo: \{}
\DoxyCodeLine{        '@type': 'git', // attributes start with @}
\DoxyCodeLine{        '\#text': 'git://github.com/oozcitak/xmlbuilder-\/js.git' // text node}
\DoxyCodeLine{      \}}
\DoxyCodeLine{    \}}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\}); }

\end{DoxyCode}


If you need to do some processing\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var root = builder.create('squares');}
\DoxyCodeLine{root.com('f(x) = x\string^2');}
\DoxyCodeLine{for(var i = 1; i <= 5; i++)}
\DoxyCodeLine{\{}
\DoxyCodeLine{  var item = root.ele('data');}
\DoxyCodeLine{  item.att('x', i);}
\DoxyCodeLine{  item.att('y', i * i);}
\DoxyCodeLine{\} }

\end{DoxyCode}


This will result in\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<?xml version="{}1.0"{}?>}
\DoxyCodeLine{<squares>}
\DoxyCodeLine{  <!-\/-\/ f(x) = x\string^2 -\/-\/>}
\DoxyCodeLine{  <data x="{}1"{} y="{}1"{}/>}
\DoxyCodeLine{  <data x="{}2"{} y="{}4"{}/>}
\DoxyCodeLine{  <data x="{}3"{} y="{}9"{}/>}
\DoxyCodeLine{  <data x="{}4"{} y="{}16"{}/>}
\DoxyCodeLine{  <data x="{}5"{} y="{}25"{}/>}
\DoxyCodeLine{</squares> }

\end{DoxyCode}


See the \href{https://github.com/oozcitak/xmlbuilder-js/wiki}{\texttt{ wiki}} for details and \href{https://github.com/oozcitak/xmlbuilder-js/wiki/Examples}{\texttt{ examples}} for more complex examples. 