buglabs / node-xml2json

Converts XML to JSON using node-expat
809 stars 210 forks source link

Feature proposal : line breaks and indentation #167

Open ggrimbert opened 6 years ago

ggrimbert commented 6 years ago

Hi,

I use your lib for parsing XML and writing JSON into XML and it's very cool and easy to use :)

But the xml generated is on one line, and I find it pretty hard to read. So I modified your code on my computer to generate the xml with line breaks and indent.

Does this feature interests you, in which case i create a PR ?

JuliaLid commented 5 years ago

I second this request! Otherwise, it's by far the best library I've found for reversible XML to JSON conversions.

@ggrimbert , how did you format the XML output of the parser.toXML() method to have line breaks and indent?

ggrimbert commented 5 years ago

Sorry for the late response. I don't have access anymore at the code I've changed...

If I remember, you have to modify the functions openTag and closeTag in xml2json.js to add the line breaks (\n) and the tabs (\t) add somes checks to control the depth and it's done

EDIT : You can have access to my version with line breaks and indent in this version https://github.com/konnecteam/node-xml2json