pixl-xml
pixl-xml copied to clipboard
Allow Disabling / Configuring of xml_header
It'd be convenient if this library offered the ability to compose raw XML strings, i.e., without including the xml_header + eol pair at the beginning of all composed documents.
You can do this by passing 1 to the indent argument of XML.stringify(). By specifying an indent level of 1 instead of 0, it skips the header.
Example:
var XML = require('pixl-xml');
var xml_string = '<?xml version="1.0"?><Document>' +
'<Simple>Hello</Simple>' +
'<Node Key="Value">Complex</Node>' +
'</Document>';
var doc = XML.parse( xml_string );
var xml_string = XML.stringify( doc, 'Document', 1, "", "" );
console.log( xml_string );
This outputs:
<Document><Node>Complex</Node><Simple>Hello</Simple></Document>