Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 598 forks source link

Text nodes erroneously combined #608

Open pjlsergeant opened 3 years ago

pjlsergeant commented 3 years ago
const {parseStringPromise, Builder} = require('xml2js');
parseStringPromise( '<apple>banana<carrot />durian</apple>' ).then( x => {
    console.log( (new Builder()).buildObject( x ));
} )

Expected output: <apple>banana<carrot />durian</apple> Actual output: <apple>bananadurian<carrot /></apple>

xml2js@0.4.23 on v14.16.1

Looking at the interim form of document created, this seems to be a bug with node-xml2js and not the builder: { apple: { _: 'bananadurian', carrot: [ '' ] } }