I am using xml-flow npm package to parse XML using streams. Issue is that the xml nodes are getting parsed in an unexpected way.
Well! After going through the implementation of these packages, it seems there is no workaround for this problem (I might have missed something) unless explicit support is provided.
I finally decided to write a new logic & ended up writing a new npm package xtreamer which provides xml nodes instead of converting them into JSON objects.
This package exposes a transform stream that can be piped with any readable stream. It expects xml node name in request and emits a custom event xmldata to output the xml node.
The output can the be plugged in to any xml-json npm package as per the requirement to get the final JSON. Check the npm package for further details.
supporting module
I managed to create one more npm package xtagger which uses sax npm package and provides xml structure in following format -
structure: { [name: string]: { [hierarchy: number]: number } };
This package can be used to find the repeating nodes in xml file by considering their hierarchy.