Video of XML splitter script for splitting XML files
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;
}
There is also another article about how to split XML with the editor and naming the output files based on information contained in the XML.
See also:
Format XML, indent align beautify clean up XML
Tree customization in the firstobject XML editor
firstobject Access Language
Counting XML tag names and values with foal
Convert ANSI file to Unicode

