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.

The Preserve Structure option would accomplish the same thing, but it would include all XML nodes prior to the first ORDER element, including the XML comment. In this example we do not want the XML comment and to achieve that, the Threshold option is used. When the name of an element is entered into the Threshold input box (it may be typed or dragged and dropped from the Viewer) XmlSplit ignores all nodes until the first ORDER element is reached, with the exception that if the Write Header option is checked the root and header elements are written.

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.

Wizard Options For this example
example3

First two split files created are below:

Split file 1.

Split file 2.