How to split large XML files in WordPress for Windows, Mac and Linux users

A comparatively larger file size for the XML WP posts would have definitely bothered you during WP site/blog migration from one host/server to another. If you’re the one who’s heard a lot about the pros of splitting large-sized XML files into smaller files and wants to dig deeper into the method utilized for the same then going through this tutorial would serve as a handy option.

What’s in store for you?

In this tutorial, I’ve covered all the steps that are involved with splitting large XML files in WordPress. The best part is that you’ll get to know about performing this operation for all the three operating systems viz: Windows, Mac and Linux.

Firstly, let’s get to know how we can split large XML files in WordPress, with Windows as the operating system

Here, I’ll explain you the usage of two incredibly amazing tools that allow you to divide a heavy XML file into several tiny files.

Tool No.1- OOXP Spiltter

This is an open source tool which allows you to break down large XML files into different files with a smaller size. The best thing about this tool is that it enables you to maintain the parent and child relationship of the WP files and their XML based validation. To download and install the OOXP Splitter tool, you just need to go to this link: http://sourceforge.net/projects/splitthatxml/

Here is the screen-shot for the OOXP Splitter tool:

ooxp spiltter tool

As you can see in the above screen-shot, in order to use this tool, you need to run the Executable files(ones with the extension as .exe), followed by loading the XML data file and XML Schema file. Once you’re done with this, you need to specify a minimum and maximum file size(in KB) and finally click on the ‘Generate Partitions’ button.

Tool No.2- WordPress WXR File Splitter

Yet another brilliant tool for splitting large XML files in WordPress is WordPress WXR File Splitter. You can go to this link: http://www.rangerpretzel.com/content/view/20/1/ for downloading the same. You just need to run the software program post downloading the same. The screen shots for this tool are displayed below:

WXR File Splitter

On the above screen, click on ‘Run’ button to reach a new screen as displayed below:

WXR File Splitter

On the above screen, simply click on ‘Open WXR File’ button for importing/uploading the XML file that needs to be broken into multiple smaller files. After uploading this XML file and entering specifications for fields viz: ‘Split File into parts of’ and ‘Total number of files’, click on ‘Split Files’ button to split the large XML file into smaller files which will then be displayed as shown in the below screen-shot:

WXR File Splitter 3

Now, let’s get to know how you can split a large-sized XML file into multiple smaller files with MAC as the operating system

Here, you require a script called “mainSplit” written in the Python programming language. Follow the below steps for breaking the XML file into smaller files:

Step 1- Go to the Introduction page of the XML file that needs to be split. Here, opt for downloading the mainSplit.py script. Once you’re done with the download, go to Applications-> Utilities folder and open the terminal where you need to enter the python mainSplit.py. The screen-shot for this is shown below:

5

Step 2– After running the mainSplit.py command(as explained in step no.1), your WordPress XML Splitter will look like this:

WordPress XML Splitter

On the above screen, for ‘Source’ section, click on ‘Browse file’ button to upload the XML file that needs to be split. Also, within the ‘Output Dir’ section, click on ‘Browse Dir’ button to upload the folder path where you want to save the split XML file. Finally, click on ‘Start’ button to initiate the XML file splitting process. Once the process is complete, you can go to your directory(this is the folder where you’ve chosen to save the split XML files) and see the large XML file broken down into smaller files with size less than 2MB.

Finally, let me make you familiar with the method utilized for breaking down a single large-sized XML file into multiple smaller files, with Linux as the operating system

Here, you just need to use the xml_split command which will either split the XML file in a tree form, keeping XML file as the parent and smaller files as children or in accordance to a specific scenario. Irrespective of the approach chosen for splitting the XML file, each smaller file will be replaced by an instruction with format as: “<?merge subdocs=[01] :<filename> ?>”. This instruction will allow “xml_merge” command to regenerate the document in its default form. Moreover, all the smaller-sized files will now have names as <file>-<nb>.xml and <file>-00.xml in relation to the main XML file.

In Conclusion

Here’s hoping the details covered in the above tutorial would definitely serve as your handy guide, the next time you plan to segregate your heavy XML files into smaller-sized files.

Author Bio – Being a passionate PSD to WordPress developer at Designs2HTML, Sarah spends most of the time in learning and researching about the new technologies and share his knowledge with the people through his creative blogs.

Leave a Reply

Your email address will not be published. Required fields are marked *