This screencast video demonstrates splitting a large XML file with the free firstobject XML editor (be sure to get release 2.3.5 or later), much the same as I explained how to do with CMarkup in the article Split XML file into smaller pieces. Below the video you will find a copy of the script used in the video.
Here is the script shown in the video. I've highlighted the following things you will need to change to fit your own purposes:
50MB.xml
- open your own input filename//ACT
- loop through the elements in the input file that you need to transferpiece
- name your output filessplit() { CMarkup xmlInput, xmlOutput; xmlInput.Open( "50MB.xml", MDF_READFILE ); int nObjectCount = 0, nFileCount = 0; while ( xmlInput.FindElem("//ACT") ) { if ( nObjectCount == 0 ) { ++nFileCount; xmlOutput.Open( "piece" + nFileCount + ".xml", MDF_WRITEFILE ); xmlOutput.AddElem( "root" ); xmlOutput.IntoElem(); } xmlOutput.AddSubDoc( xmlInput.GetSubDoc() ); ++nObjectCount; if ( nObjectCount == 5 ) { xmlOutput.Close(); nObjectCount = 0; } } if ( nObjectCount ) xmlOutput.Close(); xmlInput.Close(); return nFileCount; }
Also, see How to generate file names with XML splitter script if you need to use information contained in the XML to name the output files.
See also:
How to generate file names with XML splitter script
Split XML file into smaller pieces
Format XML, indent align beautify clean up XML
Tree customization in the firstobject XML editor