You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm not expert in javascript/node so I'm probably doing something wrong but, could someone please help and tell me why the error is not being caught in .on('endElement', f1) when f1 contains errors?
'use strict';
const XmlStream = require('xml-stream')
const fs = require('fs')
let s1 = fs.ReadStream('node_modules/xml-stream/examples/collect-preserve.xml')
let x1 = new XmlStream(s1)
x1.on('error', () => {console.log('Error never caught')})
x1.collect('subitem')
x1.on('endElement: item', f1)
function f1(xmlItem) {
console.log('enter function')
// console.log(undefined.split()) // error never caught
console.log(xmlItem)
console.log('leave function')
}
/* expected output:
enter function
{ subitem: [ 'one', 'two', 'three' ], '$text': '1 2 3' }
leave function
enter function
{ subitem: [ 'four', { letter: 'B', '$text': 'five' } ],
'$text': '4 5' }
leave function
received output:
enter function
*/
The text was updated successfully, but these errors were encountered:
Hi, I'm not expert in javascript/node so I'm probably doing something wrong but, could someone please help and tell me why the error is not being caught in .on('endElement', f1) when f1 contains errors?
The text was updated successfully, but these errors were encountered: