Ever had the urge to parse XML? And wanted to access the data in some sane, easy way? Don\textquotesingle{}t want to compile a C parser, for whatever reason? Then xml2js is what you\textquotesingle{}re looking for!\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34256}{}\doxysection{Description}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34256}
Simple XML to Java\+Script object converter. It supports bi-\/directional conversion. Uses \href{https://github.com/isaacs/sax-js/}{\texttt{ sax-\/js}} and \href{https://github.com/oozcitak/xmlbuilder-js/}{\texttt{ xmlbuilder-\/js}}.

Note\+: If you\textquotesingle{}re looking for a full DOM parser, you probably want \href{https://github.com/tmpvar/jsdom}{\texttt{ JSDom}}.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34257}{}\doxysection{Installation}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34257}
Simplest way to install {\ttfamily xml2js} is to use \href{http://npmjs.org}{\texttt{ npm}}, just {\ttfamily npm install xml2js} which will download xml2js and all dependencies.

xml2js is also available via \href{http://bower.io/}{\texttt{ Bower}}, just {\ttfamily bower install xml2js} which will download xml2js and all dependencies.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34258}{}\doxysection{Usage}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34258}
No extensive tutorials required because you are a smart developer! The task of parsing XML should be an easy one, so let\textquotesingle{}s make it so! Here\textquotesingle{}s some examples.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34259}{}\doxysubsection{Shoot-\/and-\/forget usage}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34259}
You want to parse XML as simple and easy as possible? It\textquotesingle{}s dangerous to go alone, take this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var parseString = require('xml2js').parseString;}
\DoxyCodeLine{var xml = "{}<root>Hello xml2js!</root>"{}}
\DoxyCodeLine{parseString(xml, function (err, result) \{}
\DoxyCodeLine{    console.dir(result);}
\DoxyCodeLine{\}); }

\end{DoxyCode}


Can\textquotesingle{}t get easier than this, right? This works starting with {\ttfamily xml2js} 0.\+2.\+3. With Coffee\+Script it looks like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\{parseString\} = require 'xml2js'}
\DoxyCodeLine{xml = "{}<root>Hello xml2js!</root>"{}}
\DoxyCodeLine{parseString xml, (err, result) -\/>}
\DoxyCodeLine{    console.dir result }

\end{DoxyCode}


If you need some special options, fear not, {\ttfamily xml2js} supports a number of options (see below), you can specify these as second argument\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{parseString(xml, \{trim: true\}, function (err, result) \{}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34260}{}\doxysubsection{Simple as pie usage}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34260}
That\textquotesingle{}s right, if you have been using xml-\/simple or a home-\/grown wrapper, this was added in 0.\+1.\+11 just for you\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var fs = require('fs'),}
\DoxyCodeLine{    xml2js = require('xml2js');}
\DoxyCodeLine{}
\DoxyCodeLine{var parser = new xml2js.Parser();}
\DoxyCodeLine{fs.readFile(\_\_dirname + '/foo.xml', function(err, data) \{}
\DoxyCodeLine{    parser.parseString(data, function (err, result) \{}
\DoxyCodeLine{        console.dir(result);}
\DoxyCodeLine{        console.log('Done');}
\DoxyCodeLine{    \});}
\DoxyCodeLine{\}); }

\end{DoxyCode}


Look ma, no event listeners!

You can also use {\ttfamily xml2js} from \href{https://github.com/jashkenas/coffeescript}{\texttt{ Coffee\+Script}}, further reducing the clutter\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{fs = require 'fs',}
\DoxyCodeLine{xml2js = require 'xml2js'}
\DoxyCodeLine{}
\DoxyCodeLine{parser = new xml2js.Parser()}
\DoxyCodeLine{fs.readFile \_\_dirname + '/foo.xml', (err, data) -\/>}
\DoxyCodeLine{  parser.parseString data, (err, result) -\/>}
\DoxyCodeLine{    console.dir result}
\DoxyCodeLine{    console.log 'Done.' }

\end{DoxyCode}


But what happens if you forget the {\ttfamily new} keyword to create a new {\ttfamily Parser}? In the middle of a nightly coding session, it might get lost, after all. Worry not, we got you covered! Starting with 0.\+2.\+8 you can also leave it out, in which case {\ttfamily xml2js} will helpfully add it for you, no bad surprises and inexplicable bugs!\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34261}{}\doxysubsection{Promise usage}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34261}

\begin{DoxyCode}{0}
\DoxyCodeLine{var xml2js = require('xml2js');}
\DoxyCodeLine{var xml = '<foo></foo>';}
\DoxyCodeLine{}
\DoxyCodeLine{// With parser}
\DoxyCodeLine{var parser = new xml2js.Parser(/* options */);}
\DoxyCodeLine{parser.parseStringPromise(data).then(function (result) \{}
\DoxyCodeLine{  console.dir(result);}
\DoxyCodeLine{  console.log('Done');}
\DoxyCodeLine{\})}
\DoxyCodeLine{.catch(function (err) \{}
\DoxyCodeLine{  // Failed}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Without parser}
\DoxyCodeLine{xml2js.parseStringPromise(data /*, options */).then(function (result) \{}
\DoxyCodeLine{  console.dir(result);}
\DoxyCodeLine{  console.log('Done');}
\DoxyCodeLine{\})}
\DoxyCodeLine{.catch(function (err) \{}
\DoxyCodeLine{  // Failed}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34262}{}\doxysubsection{Parsing multiple files}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34262}
If you want to parse multiple files, you have multiple possibilities\+:


\begin{DoxyItemize}
\item You can create one {\ttfamily xml2js.\+Parser} per file. That\textquotesingle{}s the recommended one and is promised to always {\itshape just work}.
\item You can call {\ttfamily reset()} on your parser object.
\item You can hope everything goes well anyway. This behaviour is not guaranteed work always, if ever. Use option \#1 if possible. Thanks!
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34263}{}\doxysubsection{So you wanna some JSON?}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34263}
Just wrap the {\ttfamily result} object in a call to {\ttfamily JSON.\+stringify} like this {\ttfamily JSON.\+stringify(result)}. You get a string containing the JSON representation of the parsed object that you can feed to JSON-\/hungry consumers.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34264}{}\doxysubsection{Displaying results}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34264}
You might wonder why, using {\ttfamily console.\+dir} or {\ttfamily console.\+log} the output at some level is only {\ttfamily \mbox{[}Object\mbox{]}}. Don\textquotesingle{}t worry, this is not because {\ttfamily xml2js} got lazy. That\textquotesingle{}s because Node uses {\ttfamily util.\+inspect} to convert the object into strings and that function stops after {\ttfamily depth=2} which is a bit low for most XML.

To display the whole deal, you can use {\ttfamily console.\+log(util.\+inspect(result, false, null))}, which displays the whole result.

So much for that, but what if you use \href{https://github.com/cloudhead/eyes.js}{\texttt{ eyes}} for nice colored output and it truncates the output with {\ttfamily …}? Don\textquotesingle{}t fear, there\textquotesingle{}s also a solution for that, you just need to increase the {\ttfamily max\+Length} limit by creating a custom inspector `var inspect = require(\textquotesingle{}eyes').inspector(\{max\+Length\+: false\}){\ttfamily and then you can easily}inspect(result)\`{}.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34265}{}\doxysubsection{XML builder usage}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34265}
Since 0.\+4.\+0, objects can be also be used to build XML\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var xml2js = require('xml2js');}
\DoxyCodeLine{}
\DoxyCodeLine{var obj = \{name: "{}Super"{}, Surname: "{}Man"{}, age: 23\};}
\DoxyCodeLine{}
\DoxyCodeLine{var builder = new xml2js.Builder();}
\DoxyCodeLine{var xml = builder.buildObject(obj); }

\end{DoxyCode}


At the moment, a one to one bi-\/directional conversion is guaranteed only for default configuration, except for {\ttfamily attrkey}, {\ttfamily charkey} and {\ttfamily explicit\+Array} options you can redefine to your taste. Writing CDATA is supported via setting the {\ttfamily cdata} option to {\ttfamily true}.

To specify attributes\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{var xml2js = require('xml2js');}
\DoxyCodeLine{}
\DoxyCodeLine{var obj = \{root: \{\$: \{id: "{}my id"{}\}, \_: "{}my inner text"{}\}\};}
\DoxyCodeLine{}
\DoxyCodeLine{var builder = new xml2js.Builder();}
\DoxyCodeLine{var xml = builder.buildObject(obj); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34266}{}\doxysubsubsection{Adding xmlns attributes}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34266}
You can generate XML that declares XML namespace prefix / URI pairs with xmlns attributes.

Example declaring a default namespace on the root element\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{let obj = \{ }
\DoxyCodeLine{  Foo: \{}
\DoxyCodeLine{    \$: \{}
\DoxyCodeLine{      "{}xmlns"{}: "{}http://foo.com"{}}
\DoxyCodeLine{    \}   }
\DoxyCodeLine{  \}}
\DoxyCodeLine{\};   }

\end{DoxyCode}
 Result of {\ttfamily build\+Object(obj)}\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{<\textcolor{keywordtype}{Foo} \textcolor{keyword}{xmlns}=\textcolor{stringliteral}{"{}http://foo.com"{}}/> }

\end{DoxyCode}
 Example declaring non-\/default namespaces on non-\/root elements\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{let obj = \{}
\DoxyCodeLine{  'foo:Foo': \{}
\DoxyCodeLine{    \$: \{}
\DoxyCodeLine{      'xmlns:foo': 'http://foo.com'}
\DoxyCodeLine{    \},}
\DoxyCodeLine{    'bar:Bar': \{}
\DoxyCodeLine{      \$: \{}
\DoxyCodeLine{        'xmlns:bar': 'http://bar.com'}
\DoxyCodeLine{      \}}
\DoxyCodeLine{    \}}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}
 Result of {\ttfamily build\+Object(obj)}\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{<\textcolor{keywordtype}{foo:Foo} \textcolor{keyword}{xmlns:foo}=\textcolor{stringliteral}{"{}http://foo.com"{}}>}
\DoxyCodeLine{  <\textcolor{keywordtype}{bar:Bar} \textcolor{keyword}{xmlns:bar}=\textcolor{stringliteral}{"{}http://bar.com"{}}/>}
\DoxyCodeLine{</\textcolor{keywordtype}{foo:Foo}> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34267}{}\doxysubsection{Processing attribute, tag names and values}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34267}
Since 0.\+4.\+1 you can optionally provide the parser with attribute name and tag name processors as well as element value processors (Since 0.\+4.\+14, you can also optionally provide the parser with attribute value processors)\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{function nameToUpperCase(name)\{}
\DoxyCodeLine{    return name.toUpperCase();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{//transform all attribute and tag names and values to uppercase}
\DoxyCodeLine{parseString(xml, \{}
\DoxyCodeLine{  tagNameProcessors: [nameToUpperCase],}
\DoxyCodeLine{  attrNameProcessors: [nameToUpperCase],}
\DoxyCodeLine{  valueProcessors: [nameToUpperCase],}
\DoxyCodeLine{  attrValueProcessors: [nameToUpperCase]\},}
\DoxyCodeLine{  function (err, result) \{}
\DoxyCodeLine{    // processed data}
\DoxyCodeLine{\}); }

\end{DoxyCode}


The {\ttfamily tag\+Name\+Processors} and {\ttfamily attr\+Name\+Processors} options accept an {\ttfamily Array} of functions with the following signature\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{function (name)\{}
\DoxyCodeLine{  //do something with `name`}
\DoxyCodeLine{  return name}
\DoxyCodeLine{\} }

\end{DoxyCode}


The {\ttfamily attr\+Value\+Processors} and {\ttfamily value\+Processors} options accept an {\ttfamily Array} of functions with the following signature\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{function (value, name) \{}
\DoxyCodeLine{  //`name` will be the node name or attribute name}
\DoxyCodeLine{  //do something with `value`, (optionally) dependent on the node/attr name}
\DoxyCodeLine{  return value}
\DoxyCodeLine{\} }

\end{DoxyCode}


Some processors are provided out-\/of-\/the-\/box and can be found in {\ttfamily lib/processors.\+js}\+:


\begin{DoxyItemize}
\item {\ttfamily normalize}\+: transforms the name to lowercase. (Automatically used when {\ttfamily options.\+normalize} is set to {\ttfamily true})
\item {\ttfamily first\+Char\+Lower\+Case}\+: transforms the first character to lower case. E.\+g. \textquotesingle{}My\+Tag\+Name\textquotesingle{} becomes \textquotesingle{}my\+Tag\+Name\textquotesingle{}
\item {\ttfamily strip\+Prefix}\+: strips the xml namespace prefix. E.\+g {\ttfamily $<$foo\+:Bar/$>$} will become \textquotesingle{}Bar\textquotesingle{}. (N.\+B.\+: the {\ttfamily xmlns} prefix is NOT stripped.)
\item {\ttfamily parse\+Numbers}\+: parses integer-\/like strings as integers and float-\/like strings as floats E.\+g. \char`\"{}0\char`\"{} becomes 0 and \char`\"{}15.\+56\char`\"{} becomes 15.\+56
\item {\ttfamily parse\+Booleans}\+: parses boolean-\/like strings to booleans E.\+g. \char`\"{}true\char`\"{} becomes true and \char`\"{}\+False\char`\"{} becomes false
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34268}{}\doxysection{Options}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34268}
Apart from the default settings, there are a number of options that can be specified for the parser. Options are specified by {\ttfamily new Parser(\{option\+Name\+: value\})}. Possible options are\+:


\begin{DoxyItemize}
\item {\ttfamily attrkey} (default\+: {\ttfamily \$})\+: Prefix that is used to access the attributes. Version 0.\+1 default was {\ttfamily @}.
\item {\ttfamily charkey} (default\+: {\ttfamily \+\_\+})\+: Prefix that is used to access the character content. Version 0.\+1 default was {\ttfamily \#}.
\item {\ttfamily explicit\+Charkey} (default\+: {\ttfamily false})
\item {\ttfamily trim} (default\+: {\ttfamily false})\+: Trim the whitespace at the beginning and end of text nodes.
\item {\ttfamily normalize\+Tags} (default\+: {\ttfamily false})\+: Normalize all tag names to lowercase.
\item {\ttfamily normalize} (default\+: {\ttfamily false})\+: Trim whitespaces inside text nodes.
\item {\ttfamily explicit\+Root} (default\+: {\ttfamily true})\+: Set this if you want to get the root node in the resulting object.
\item {\ttfamily empty\+Tag} (default\+: `'\textquotesingle{}{\ttfamily )\+: what will the value of empty nodes be. $\ast$}explicit\+Array{\ttfamily (default\+:}true\`{})\+: Always put child nodes in an array if true; otherwise an array is created only if there is more than one.
\item {\ttfamily ignore\+Attrs} (default\+: {\ttfamily false})\+: Ignore all XML attributes and only create text nodes.
\item {\ttfamily merge\+Attrs} (default\+: {\ttfamily false})\+: Merge attributes and child elements as properties of the parent, instead of keying attributes off a child attribute object. This option is ignored if {\ttfamily ignore\+Attrs} is {\ttfamily true}.
\item {\ttfamily validator} (default {\ttfamily null})\+: You can specify a callable that validates the resulting structure somehow, however you want. See unit tests for an example.
\item {\ttfamily xmlns} (default {\ttfamily false})\+: Give each element a field usually called \textquotesingle{}\$ns\textquotesingle{} (the first character is the same as attrkey) that contains its local name and namespace URI.
\item {\ttfamily explicit\+Children} (default {\ttfamily false})\+: Put child elements to separate property. Doesn\textquotesingle{}t work with {\ttfamily merge\+Attrs = true}. If element has no children then \char`\"{}children\char`\"{} won\textquotesingle{}t be created. Added in 0.\+2.\+5.
\item {\ttfamily childkey} (default {\ttfamily \$\$})\+: Prefix that is used to access child elements if {\ttfamily explicit\+Children} is set to {\ttfamily true}. Added in 0.\+2.\+5.
\item {\ttfamily preserve\+Children\+Order} (default {\ttfamily false})\+: Modifies the behavior of {\ttfamily explicit\+Children} so that the value of the \char`\"{}children\char`\"{} property becomes an ordered array. When this is {\ttfamily true}, every node will also get a {\ttfamily \#name} field whose value will correspond to the XML node\+Name, so that you may iterate the \char`\"{}children\char`\"{} array and still be able to determine node names. The named (and potentially unordered) properties are also retained in this configuration at the same level as the ordered \char`\"{}children\char`\"{} array. Added in 0.\+4.\+9.
\item {\ttfamily chars\+As\+Children} (default {\ttfamily false})\+: Determines whether chars should be considered children if {\ttfamily explicit\+Children} is on. Added in 0.\+2.\+5.
\item {\ttfamily include\+White\+Chars} (default {\ttfamily false})\+: Determines whether whitespace-\/only text nodes should be included. Added in 0.\+4.\+17.
\item {\ttfamily async} (default {\ttfamily false})\+: Should the callbacks be async? This {\itshape might} be an incompatible change if your code depends on sync execution of callbacks. Future versions of {\ttfamily xml2js} might change this default, so the recommendation is to not depend on sync execution anyway. Added in 0.\+2.\+6.
\item {\ttfamily strict} (default {\ttfamily true})\+: Set sax-\/js to strict or non-\/strict parsing mode. Defaults to {\ttfamily true} which is {\itshape highly} recommended, since parsing HTML which is not well-\/formed XML might yield just about anything. Added in 0.\+2.\+7.
\item {\ttfamily attr\+Name\+Processors} (default\+: {\ttfamily null})\+: Allows the addition of attribute name processing functions. Accepts an {\ttfamily Array} of functions with following signature\+: \`{}\`{}\`{}javascript function (name)\{ //do something with {\ttfamily name} return name \} \`{}\`{}\`{} Added in 0.\+4.\+14
\item {\ttfamily attr\+Value\+Processors} (default\+: {\ttfamily null})\+: Allows the addition of attribute value processing functions. Accepts an {\ttfamily Array} of functions with following signature\+: \`{}\`{}\`{}javascript function (value, name)\{ //do something with {\ttfamily name} return name \} \`{}\`{}\`{} Added in 0.\+4.\+1
\item {\ttfamily tag\+Name\+Processors} (default\+: {\ttfamily null})\+: Allows the addition of tag name processing functions. Accepts an {\ttfamily Array} of functions with following signature\+: \`{}\`{}\`{}javascript function (name)\{ //do something with {\ttfamily name} return name \} \`{}\`{}\`{} Added in 0.\+4.\+1
\item {\ttfamily value\+Processors} (default\+: {\ttfamily null})\+: Allows the addition of element value processing functions. Accepts an {\ttfamily Array} of functions with following signature\+: \`{}\`{}\`{}javascript function (value, name)\{ //do something with {\ttfamily name} return name \} \`{}\`{}\`{} Added in 0.\+4.\+6
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34269}{}\doxysubsection{Options for the $<$tt$>$\+Builder$<$/tt$>$ class}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34269}
These options are specified by {\ttfamily new Builder(\{option\+Name\+: value\})}. Possible options are\+:


\begin{DoxyItemize}
\item {\ttfamily attrkey} (default\+: {\ttfamily \$})\+: Prefix that is used to access the attributes. Version 0.\+1 default was {\ttfamily @}.
\item {\ttfamily charkey} (default\+: {\ttfamily \+\_\+})\+: Prefix that is used to access the character content. Version 0.\+1 default was {\ttfamily \#}.
\item {\ttfamily root\+Name} (default {\ttfamily root} or the root key name)\+: root element name to be used in case {\ttfamily explicit\+Root} is {\ttfamily false} or to override the root element name.
\item {\ttfamily render\+Opts} (default `\{ \textquotesingle{}pretty'\+: true, \textquotesingle{}indent\textquotesingle{}\+: \textquotesingle{} \textquotesingle{}, \textquotesingle{}newline\textquotesingle{}\+: \textquotesingle{}~\newline
\textquotesingle{} \}\`{})\+: Rendering options for xmlbuilder-\/js.
\begin{DoxyItemize}
\item pretty\+: prettify generated XML
\item indent\+: whitespace for indentation (only when pretty)
\item newline\+: newline char (only when pretty)
\end{DoxyItemize}
\item {\ttfamily xmldec} (default `\{ \textquotesingle{}version'\+: \textquotesingle{}1.\+0\textquotesingle{}, \textquotesingle{}encoding\textquotesingle{}\+: \textquotesingle{}UTF-\/8\textquotesingle{}, \textquotesingle{}standalone\textquotesingle{}\+: true \}\`{}\+: XML declaration attributes.
\begin{DoxyItemize}
\item {\ttfamily xmldec.\+version} A version number string, e.\+g. 1.\+0
\item {\ttfamily xmldec.\+encoding} Encoding declaration, e.\+g. UTF-\/8
\item {\ttfamily xmldec.\+standalone} standalone document declaration\+: true or false
\end{DoxyItemize}
\item {\ttfamily doctype} (default {\ttfamily null})\+: optional DTD. Eg. `\{\textquotesingle{}ext'\+: \textquotesingle{}hello.\+dtd\textquotesingle{}\}{\ttfamily  $\ast$}headless{\ttfamily (default\+:}false{\ttfamily )\+: omit the XML header. Added in 0.\+4.\+3. $\ast$}allow\+Surrogate\+Chars{\ttfamily (default\+:}false\`{})\+: allows using characters from the Unicode surrogate blocks.
\item {\ttfamily cdata} (default\+: {\ttfamily false})\+: wrap text nodes in {\ttfamily $<$!\mbox{[}CDATA\mbox{[} ... \mbox{]}\mbox{]}$>$} instead of escaping when necessary. Does not add {\ttfamily $<$!\mbox{[}CDATA\mbox{[} ... \mbox{]}\mbox{]}$>$} if it is not required. Added in 0.\+4.\+5.
\end{DoxyItemize}

{\ttfamily render\+Opts}, {\ttfamily xmldec},{\ttfamily doctype} and {\ttfamily headless} pass through to \href{https://github.com/oozcitak/xmlbuilder-js}{\texttt{ xmlbuilder-\/js}}.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34270}{}\doxysection{Updating to new version}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34270}
Version 0.\+2 changed the default parsing settings, but version 0.\+1.\+14 introduced the default settings for version 0.\+2, so these settings can be tried before the migration.


\begin{DoxyCode}{0}
\DoxyCodeLine{var xml2js = require('xml2js');}
\DoxyCodeLine{var parser = new xml2js.Parser(xml2js.defaults["{}0.2"{}]); }

\end{DoxyCode}


To get the 0.\+1 defaults in version 0.\+2 you can just use {\ttfamily xml2js.\+defaults\mbox{[}\char`\"{}0.\+1\char`\"{}\mbox{]}} in the same place. This provides you with enough time to migrate to the saner way of parsing in {\ttfamily xml2js} 0.\+2. We try to make the migration as simple and gentle as possible, but some breakage cannot be avoided.

So, what exactly did change and why? In 0.\+2 we changed some defaults to parse the XML in a more universal and sane way. So we disabled {\ttfamily normalize} and {\ttfamily trim} so {\ttfamily xml2js} does not cut out any text content. You can reenable this at will of course. A more important change is that we return the root tag in the resulting Java\+Script structure via the {\ttfamily explicit\+Root} setting, so you need to access the first element. This is useful for anybody who wants to know what the root node is and preserves more information. The last major change was to enable {\ttfamily explicit\+Array}, so everytime it is possible that one might embed more than one sub-\/tag into a tag, xml2js $>$= 0.\+2 returns an array even if the array just includes one element. This is useful when dealing with APIs that return variable amounts of subtags.\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34271}{}\doxysection{Running tests, development}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34271}
\href{https://travis-ci.org/Leonidas-from-XIV/node-xml2js}{\texttt{ }} \href{https://coveralls.io/r/Leonidas-from-XIV/node-xml2js?branch=master}{\texttt{ }} \href{https://david-dm.org/Leonidas-from-XIV/node-xml2js}{\texttt{ }}

The development requirements are handled by npm, you just need to install them. We also have a number of unit tests, they can be run using {\ttfamily npm test} directly from the project root. This runs zap to discover all the tests and execute them.

If you like to contribute, keep in mind that {\ttfamily xml2js} is written in Coffee\+Script, so don\textquotesingle{}t develop on the Java\+Script files that are checked into the repository for convenience reasons. Also, please write some unit test to check your behaviour and if it is some user-\/facing thing, add some documentation to this README, so people will know it exists. Thanks in advance!\hypertarget{md_sfcode_node_modules_xml2js_README_autotoc_md34272}{}\doxysection{Getting support}\label{md_sfcode_node_modules_xml2js_README_autotoc_md34272}
Please, if you have a problem with the library, first make sure you read this README. If you read this far, thanks, you\textquotesingle{}re good. Then, please make sure your problem really is with {\ttfamily xml2js}. It is? Okay, then I\textquotesingle{}ll look at it. Send me a mail and we can talk. Please don\textquotesingle{}t open issues, as I don\textquotesingle{}t think that is the proper forum for support problems. Some problems might as well really be bugs in {\ttfamily xml2js}, if so I\textquotesingle{}ll let you know to open an issue instead \+:)

But if you know you really found a bug, feel free to open an issue instead. 