Using XML Split
This tutorial will cover using the Splitting XML Files task to split XML into smaller chunks. This can be useful when dealing with large amounts of data, or when files need to be sent individually to an endpoint.
XML Split
For this tutorial, we will be using the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Products>
<Product>
<UniqueId>TEST</UniqueId>
<Sku>TEST</Sku>
<Barcode />
<Name>Test Product</Name>
</Product>
<Product>
<UniqueId>TEST2</UniqueId>
<Sku>TEST2</Sku>
<Barcode />
<Name>Test Product 2</Name>
</Product>
</Products>
</Company>
In this example, the task settings should be set as follows. Any settings not mentioned should be left at their default values:
- Input File - The file containing the XML to process. This should be set to where you've saved the above XML file.
- XPath Query - The XPath query to use for the task. This should be set to
Company/Products/Product
- Record Limit - The maximum number of records per output file. This should be set to 1.
The above task settings will create two files within the XML Splits directory, each containing a single record.
Uses of Splitting XML Files
Typically, the XML Split task will be used in conjunction with a File Repeater, which will loop over each of the smaller "chunked" files and perform some operation with each of the files in sequence.
A common use case that we come across is when integrating with websites which are running scripts expecting XML data via a HTTP POST. In some of these scenarios, when uploading data which grows over time (such as stock records), it is necessary to firstly limit the amount of data that will be contained within the files to be posted (using the XML Split task).
Another potential use is when an HTTP endpoint is only capable of receiving a single record at a time.