Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Split Large XML Files for WordPress Import

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Importing a very large WordPress XML file (often called a WXR file) often fails or times out because of server memory limits or upload size restrictions. Splitting the file into smaller, valid WordPress import files lets you import your content in manageable chunks, avoiding these errors and making the process much more reliable. This guide shows you a safe, step-by-step method using free, widely available tools.

What You'll Need

  • The large WordPress XML file you want to split (usually exported from the Tools → Export screen).
  • A plain text editor that can handle large files, such as Notepad++ (Windows), Sublime Text, or VS Code. Do not use Notepad on Windows for files over a few megabytes.
  • An XML-aware splitter tool. The easiest free option is XML Splitter by Damián Parrino (a small Windows program), or a command-line tool like xmlstarlet (available for Windows, macOS, and Linux). This guide focuses on the graphical XML Splitter because it requires no coding.
  • A backup of your original XML file stored somewhere safe.

Step-by-Step

  1. Back up your original file. Copy the large XML file to a separate folder or an external drive. Never work on the only copy you have.
  2. Check the file's structure. Open the file in your text editor. Look at the very top. You should see lines like <?xml version="1.0" encoding="UTF-8" ?> and then a root element like <rss version="2.0"> followed by <channel>. The content items are inside <item> tags. Each <item> represents a post, page, or custom post type. Your splitter needs to know this root and item structure.
  3. Install your splitter. If using XML Splitter, download it from the developer's site and unzip it. It's a portable program, so no installation is needed. If using xmlstarlet, install it via your package manager (e.g., brew install xmlstarlet on macOS, apt install xmlstarlet on Ubuntu, or download the Windows binary).
  4. Open the splitter and load your file. Launch XML Splitter. Click the folder icon to browse to your large XML file and select it. The program will read the file and show you the root element and the list of child elements it finds.
  5. Set the split element. In XML Splitter, you'll see a field for "Root Element" and "Split Element". The root should be rss (or whatever your root is). The split element should be item. This tells the tool to break the file at each <item> boundary.
  6. Choose your split size. Decide how many items you want per output file. A safe number for most WordPress installs is between 50 and 200 items per file. If your items are large (lots of images or long content), start with 50. If they are small, 200 is fine. You can also split by file size (e.g., 2 MB per file) if your host has a strict upload limit.
  7. Select an output folder. Choose a new, empty folder where the split files will be saved. Make sure it's not the same folder as your original.
  8. Run the split. Click the "Split" button. The tool will create files named like yourfile_part1.xml, yourfile_part2.xml, etc. Each file will contain the same XML header and root/channel opening tags, the specified number of <item> elements, and the closing tags. This is crucial – each file must be a complete, valid XML document.
  9. Verify a split file. Open one of the output files in your text editor. Confirm it starts with the XML declaration and ends with </channel></rss> (or your matching closing tags). If the file looks cut off or missing closing tags, the splitter did not work correctly – do not use it.
  10. Import the first file. Go to your WordPress admin → Tools → Import → WordPress. Install the WordPress Importer plugin if you haven't already. Upload the first split file. If your server has a file upload limit (e.g., 2 MB), you may need to increase it temporarily via your hosting control panel or by editing php.ini (set upload_max_filesize and post_max_size).
  11. Repeat for each file. After the first import completes, import the second file, then the third, and so on. Each import will add the posts/pages from that file. WordPress will not duplicate posts if you run the import twice – it checks for existing GUIDs.
  12. Check your site. After all files are imported, visit your site's posts and pages to confirm everything is there. Check for missing images or broken links, which can happen if the import was interrupted.

Common Mistakes

  • Splitting at the wrong element. If you split at channel instead of item, you'll get files that are not valid WordPress imports.
  • Using a regular text editor to split. Manually cutting and pasting in a text editor often breaks the XML structure, especially with large files. Use a dedicated splitter.
  • Not preserving the XML declaration. Each split file must start with <?xml version="1.0" encoding="UTF-8" ?>. Some splitters omit this if you don't configure them correctly.
  • Importing files out of order. If your posts have parent-child relationships (e.g., pages), importing the parent after the child can cause the hierarchy to be lost. Import in the order they were exported.
  • Ignoring the upload limit. Even if your split files are small, your server may still reject them if the upload limit is set too low. Check your Media Library or hosting settings.

Tips

  • Test with one file first. Before splitting the entire file, try importing a single item file to make sure your server and importer are working.
  • Increase PHP memory limit. If you get a "memory exhausted" error during import, increase the memory limit in wp-config.php by adding define('WP_MEMORY_LIMIT', '256M'); temporarily.
  • Use a local WordPress install for testing. If you're unsure about the process, try importing a split file on a local test site first.
  • Keep a log of which files you've imported. If you have many files, mark them off as you go to avoid double imports.
  • Consider using a plugin. There are WordPress plugins that can handle large imports by splitting the file for you, but the manual method gives you more control.

Troubleshooting

  • "Invalid XML" error on import. This means your split file is not well-formed. Open it in a browser – if the browser shows errors, the XML is broken. Re-split using the correct settings, ensuring the root and item elements are correct.
  • Import times out. Your split files are still too large, or your server is slow. Reduce the number of items per file (e.g., from 100 to 20) and try again.
  • "File is empty" error. The splitter may have produced a file with no items, or the file was corrupted. Check the file size – it should be at least a few kilobytes. Re-run the split.
  • Posts missing after import. If some posts don't appear, the import may have skipped them due to duplicate GUIDs or errors. Check the import log (if available) and try importing the file again – WordPress will skip duplicates.
  • Images not importing. The WordPress importer downloads images from the original site. If the original site is down or slow, images may fail. You can re-import the file later, or manually upload images.

Frequently Asked Questions

How many items should I put in each split file?

Start with 50-100 items per file. If you have a slow server, use fewer. If your items are small and your server is fast, you can go up to 200.

Can I split a WordPress XML file using Excel or Google Sheets?

No. Excel and Google Sheets are not designed for XML and will corrupt the structure. Use a dedicated XML splitter or a text editor with XML tools.

Will splitting the file affect my site's SEO or permalinks?

No. Each split file contains the same post slugs and GUIDs, so permalinks will remain the same. The import process is identical to importing one large file.

What if my XML file is not from WordPress?

The same method works for any XML file with a repeating element (like <item>). Just adjust the root and split element names accordingly.

Can I split the file on a Mac?

Yes. XML Splitter is Windows-only, but you can use xmlstarlet on macOS. Alternatively, use a free online XML splitter (though be cautious with sensitive data).

Do I need to keep the original file after splitting?

Yes, keep the original as a backup. If something goes wrong during import, you can always re-split or re-export from WordPress.