xml-flow NPM package - Unexpected XML Parsing Behaviour

前端 未结 1 839
伪装坚强ぢ
伪装坚强ぢ 2021-01-25 13:18

Background

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.

相关标签:
1条回答
  • 2021-01-25 13:52

    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.

    0 讨论(0)
提交回复
热议问题