flattenxml
v1.1.0
Published
Flattens formatted XML
Downloads
720
Readme
FlattenXML
Small JavaScript/NodeJS library that takes a formatted XML string like the following:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<SOAP-ENV:Envelope
xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<m:Something xmlns:m="http://hedgehogsareawesome.com.au">
<name>hedgehogs are awesome</name>
</m:Something>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
and makes it as flat as a pancake like so:
<SOAP-ENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><m:Something xmlns:m="http://hedgehogsareawesome.com.au"><name>hedgehogs are awesome</name></m:Something></SOAP-ENV:Body></SOAP-ENV:Envelope>
Installation
Using npm / yarn:
npm i flattenxml
yarn add flattenxml
Usage
const flattenXml = require('flattenxml')
const formattedXml = `
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<SOAP-ENV:Envelope
xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<m:Something xmlns:m="http://hedgehogsareawesome.com.au">
<name>hedgehogs are awesome</name>
</m:Something>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
`
console.log(flattenXml(formattedXml))
Credits
Made possible because of the fantastic xmldoc