node-xml icon indicating copy to clipboard operation
node-xml copied to clipboard

Multiple mixed content being ignored

Open Nokel81 opened this issue 7 years ago • 3 comments

The following is modified example from the readme:

var example5 = [{
    toys: [{
            _attr: {
                decade: '80s',
                locale: 'US'
            }
        },
        {
            toy: [{
                    _attr: {
                        decade: '80s',
                        locale: 'US'
                    }
                },
                'Transformers',
                {
                    toya: [{
                        _attr: {
                            knowing: 'half the battle'
                        }
                    }, 'GI Joe']
                }
            ]
        }
    ]
}];

And it produces

<toys decade="80s" locale="US">
    <toy decade="80s" locale="US">
        Transformers
        <toya knowing="half the battle">GI Joe</toya>
    </toy>
</toys>

However, if another piece of mixed data is added like this:

var example5 = [{
    toys: [{
            _attr: {
                decade: '80s',
                locale: 'US'
            }
        },
        {
            toy: [{
                    _attr: {
                        decade: '80s',
                        locale: 'US'
                    }
                },
                'Transformers',
                {
                    toya: [{
                        _attr: {
                            knowing: 'half the battle'
                        }
                    }, 'GI Joe']
                },
                ' and the A-team'
            ]
        }
    ]
}];

The sub object is just ignored and the following is outputted:

<toys decade="80s" locale="US">
    <toy decade="80s" locale="US">Transformers and the A-team</toy>
</toys>

Nokel81 avatar Jun 27 '17 14:06 Nokel81