flattenxml

1.1.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i flattenxml

Weekly Downloads

124

Version

1.1.0

License

MIT

Unpacked Size

3.23 kB

Total Files

5

Last publish

Collaborators

  • mrbenhowl