2 Replies Latest reply on Nov 26, 2007 7:12 PM by rkoe123

    nested repeater from XML data

    rkoe123
      Hi
      I am new to flex 2 and need help with a bit of nested repeater problem.
      I have an external xml data named "data.xml" as follow:
      <?xml version="1.0" encoding="UTF-8"?>
      <products>
      <product>
      <productno>p1</productno>
      <article>
      <articleno>a1</articleno>
      </article>
      <article>
      <articleno>a2</articleno>
      </article>
      </product>
      <product>
      <productno>p2</productno>
      <article>
      <articleno>a3</articleno>
      </article>
      </product>
      </products>

      And the .mxml code is as follow:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:XML id="data" source="data.xml" />
      <mx:VBox>
      <mx:Repeater id="Repeater1" dataProvider="{data.product}">
      <mx:Label text="{Repeater1.currentItem.productno}" />
      <mx:Repeater id="Repeater2" dataProvider="{data.product.article}">
      <mx:Label text="{Repeater2.currentItem.articleno}" />
      </mx:Repeater>
      </mx:Repeater>
      </mx:VBox>
      </mx:Application>

      The problem with the output is the child article for each parent product is being repeated:
      p1
      a1
      a2
      a3
      p2
      a1
      a2
      a3

      But what I want is:
      p1
      a1
      a2
      p2
      a3

      Can anyone pls help as to what I did wrong?

      Thanks!!