Creating recursive loops from a flat file
Use a FlatToHierarchyLoop function to create recursive loops based on levels defined in a flat file.
Before you begin
About this task
In this example you have a CSV file describing a table of contents with
        titles, page numbers and numbers corresponding to the level of each element. You want to
        create an XML file in which elements are nested based on their level. You can use the
        following sample as
        input:
         
         title,page,level
Introduction,3,1
Part 1,10,1
Chapter 1,10,2
Section 1,10,3
Section 2,31,3
Section 3,56,3
Chapter 2,80,2
Section 1,80,3
Section 2,102,3
Part 2,125,1
Chapter 1,125,2
Chapter 2,160,2
Section 1,160,3
Section 2,185,3
Conclusion,213,1You can use the following XML sample to create your output
        structure:
         
      <contents>
	<entry>
		<title/>
		<page/>
	</entry>
	<entry>
		<title/>
		<page/>
	</entry>
</contents>Procedure
Results
         
            You can use the Test Run feature to see
					the result. In this example, the following output is returned:
            
         
      <contents>
  <entry>
    <title>Introduction</title>
    <page>3</page>
  </entry>
  <entry>
    <title>Part 1</title>
    <page>10</page>
    <entry>
      <title>Chapter 1</title>
      <page>10</page>
      <entry>
        <title>Section 1</title>
        <page>10</page>
      </entry>
      <entry>
        <title>Section 2</title>
        <page>31</page>
      </entry>
      <entry>
        <title>Section 3</title>
        <page>56</page>
      </entry>
    </entry>
    <entry>
      <title>Chapter 2</title>
      <page>80</page>
      <entry>
        <title>Section 1</title>
        <page>80</page>
      </entry>
      <entry>
        <title>Section 2</title>
        <page>102</page>
      </entry>
    </entry>
  </entry>
  <entry>
    <title>Part 2</title>
    <page>125</page>
    <entry>
      <title>Chapter 1</title>
      <page>125</page>
    </entry>
    <entry>
      <title>Chapter 2</title>
      <page>160</page>
      <entry>
        <title>Section 1</title>
        <page>160</page>
      </entry>
      <entry>
        <title>Section 2</title>
        <page>185</page>
      </entry>
    </entry>
  </entry>
  <entry>
    <title>Conclusion</title>
    <page>213</page>
  </entry>
</contents>