A sample to split large xml file and encode the split xml array. Most sample codes of using xml-split are for the smaller XML files. If you are dealing with extremely large XML files, you can take a look at this one.
- Node JS 4 or above
xmlsplit
- visit https://github.com/remuslazar/node-xmlsplit
- download the folder
/lib/
xml2js
$ npm install xml2js
- To split a large XML file into smaller one:
$ node xmlsplitter.js /your/path/to/the/large.xml <xml-tag-of-the-array> <batch-size>
for instance, To split a large XML array composed by elements with tag in an XML file /home/user/the_array.xml
into small pieces. For each piece, there are 500 elements:
$ node xmlsplitter.js /home/user/the_array.xml the-array-member 500
$ node xml_to_json.js <xml-file>
For instance, to encode foo.xml
, just do
$ node xml_to_json.js foo.xml
and then a file foo.json
will be saved in the same folder.