Example 3: Split every 20 and write header in each file.

  • Insert root element of the source XML document in every split file.
  • Write the header element in each split file.
  • Use the Threshold option to skip unwanted XML comment.
  • Write 20 ORDER elments to each split file.
Sample XML file orders_header.xml containing 50 ORDER elements

Split Method A is used with 20 as the frequency value and ORDER as the element with a depth value of one(see methods tab image in Example 1).

The sample file contains element ORDER_HEADER whose purpose is to provide a description of the contents of the file. It may be included in each of the split files by checking Write Header Element on the Options tab. This option tells XmlSplit that the first element under the root is a non-repeating header and that the root element and the header element is to be written to each split file.

Since the XML comment is not wanted the Threshold option is used and the ORDER element is specified. If the Write Header option is checked, the header is written first and then XmlSplit looks for the next occurence of the Threshold element, ORDER. From there it applies the split critera

This setup writes the specified root element followed by the header element(ORDER_HEADER). When the first Threshold element, ORDER is reached, elements with a depth of 1 are written, including all child nodes, until 20 such elements have been written. Child elements are not included in the count. When 20 ORDER elements have been written, a new split file is created and these steps are repeated until the end of the source XML is reached.

Note that the same results may be accomplished using the Preserve Structure option, but to exclude the XML comment it would be necessary to open the Preserve Structure dialog (Show button) and delete the comment from the list.

Wizard Options For this example
example3

First two split files created are below:

Split file 1.

Split file 2.