simplify-xml-js

1.0.2 • Public • Published

Simplify Output from xml-js

1. Move _text property to actual property value

const simplify = require('simplify-xml-js')

// output from xml-js:
simplify({
    name: { _text: 'john doe'}
})

// becomes:
{
    name: 'john doe'
}

2. Remove namespaces from the property names

const simplify = require('simplify-xml-js')

// output from xml-js:
simplify({
    'form12:name': { _text: 'john doe'}
})

// becomes:
{
    name: 'john doe'
}

3. Remove attributes and decleartions

const simplify = require('simplify-xml-js')

// output from xml-js:
simplify({
    person: {
        _attributes: {
            xmlns: 'http://somecompany.com/format.xsd'
        },
        name: { _text: 'john doe'}
    }
})

// becomes:
{
    person: { name: 'john doe' }
}

4. Simplify values in array

const simplify = require('simplify-xml-js')

// output from xml-js:
simplify({
    phones: [
        {
            _text: '01245'
        },
        {
            _text: '05879'
        }
    ]
})

// becomes:
{
    phones: [ '012345', '05879' ]
}

Readme

Keywords

Package Sidebar

Install

npm i simplify-xml-js

Weekly Downloads

12

Version

1.0.2

License

ISC

Unpacked Size

6.05 kB

Total Files

4

Last publish

Collaborators

  • greenants