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 transfer
  • piece - name your output files
  • root - name your root element and any container elements needed in the output file
  • 5 - set the maximum of those subdocuments per output file
  • split()
      CMarkup xmlInput, xmlOutput;
      xmlInput.Open( "50MB.xml", MDF_READFILE );
      int nObjectCount = 0, nFileCount = 0;
      while ( xmlInput.FindElem("//ACT") )
        if ( nObjectCount == 0 )
          xmlOutput.Open( "piece" + nFileCount + ".xml", MDF_WRITEFILE );
          xmlOutput.AddElem( "root" );
        xmlOutput.AddSubDoc( xmlInput.GetSubDoc() );
        if ( nObjectCount == 5 )
          nObjectCount = 0;
      if ( nObjectCount )
      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

    firstobject Access Language

    Counting XML tag names and values with foal

    Convert ANSI file to Unicode