A thin wrapper around DOMParser and XMLSerializer for node and the browser.
npm install simple-xml-domsimple-xml-dom is a thin wrapper around DOMParser and XMLSerializer that makes parsing and serializing XML more pleasant. It depends on xmldom in node, and native implementations in the browser.

sh
$ npm install simple-xml-dom
`
note: xmldom is not installed alongside simple-xml-dom$3
#### Basic
The available methods are
parse and serialize.`js
var xml = require('simple-xml-dom')// Parse
var dom = xml.parse('world ')
dom.documentElement.textContent
> 'world'
// Serialize
dom.documentElement.textContent = 'dexter morgan'
xml.serialize(dom)
> 'dexter morgan '
`#### A more modular approach
Sometimes you only need to
parse or serialize, and in these cases it makes sense to only require a single method.`js
var parse = require('simple-xml-dom/parse')
var serialize = require('simple-xml-dom/serialize')serialize(parse('world'))
> 'world '
`#### Format correction
XMLSerialize collapses the whitespace surrounding declarations, so the
format method exists to restore these characters.`js
var xml = require('simple-xml-dom')
var format = require('simple-xml-dom/format')var source = '\r\nworld '
// Whitespace collapsed
xml.serialize(xml.parse(source))
> 'world '
// Whitespace restored
format(xml.serialize(xml.parse(source)), source)
> '\r\nworld '
`The second argument is optional. If present, whitespace from
source will be adopted by the serialize` output’s declarations. If not, a new-line character will be inserted after every declaration.