0

I want to read a large xml file and store the data in database. I tried xml2js but am getting error as Error: Cannot create a string longer than 0x3fffffe7 characters.

I would like to know the best practice for processing xml file, whether can i process the xml directly or converting into json using any library or breaking large file into multiple small files?

Vignesh
  • 1
  • 1
  • 1
  • 1

1 Answers1

2

You really need a streaming processor for this. Unfortunately Node.js isn't that well served by XML technology (Saxon does streaming XSLT on the Java platform, but on Node.js it is unstreamed). Your best bet is probably to write a low-level application using a SAX parser such as https://www.npmjs.com/package/sax -- though if you search for "XML SAX" on npm you will see there are others available.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164