How do I split a large xml file?

后端 未结 7 2027
小鲜肉
小鲜肉 2021-01-02 14:05

We export “records” to an xml file; one of our customers has complained that the file is too big for their other system to process. Therefore I need to split up the file,

7条回答
  •  情话喂你
    2021-01-02 14:33

    First download foxe xml editor from this link http://www.firstobject.com/foxe242.zip

    Watch that video http://www.firstobject.com/xml-splitter-script-video.htm Video explains how split code works.

    There is a script code on that page (starts with split() ) copy the code and on the xml editor program make a "New Program" under the "File". Paste the code and save it. The code is:

    split()
    {
      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;
    }
    

    Change the bold marked (or ** ** marked) fields for your needs. (this is also expressed at the video page)

    On the xml editor window right click and click the RUN (or simply F9). There is output bar on the window where it shows number of files that generated.

    Note: input File name can be "C:\\Users\\AUser\\Desktop\\a_xml_file.xml" (double slashes) and output file "C:\\Users\\AUser\\Desktop\\anoutputfolder\\piece" + nFileCount + ".xml"

提交回复
热议问题