2 Replies Latest reply on Feb 14, 2008 11:09 AM by Krellee

    XML displaying

    Krellee Level 1
      Hello everyone

      i've got a problem displaying xml in a list i know the data comes through because i can highlite the lines but. I get no text at all but just three blank spaces that i can highlite but with no data in them.

      Any ideas what i'm doing wrong?

      here is the code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;

      [Bindable]
      private var Phones:ArrayCollection = new ArrayCollection;

      private function dotQuery():void{
      for each(var xml:XML in cata.product)
      Phones.addItem(xml.price);
      }
      ]]>
      </mx:Script>


      <mx:XML id="cata" source="data/cata.xml"/>
      <mx:List dataProvider="{Phones}" creationComplete="dotQuery()" top="20" width="75%" horizontalCenter="0" fontFamily="Arial" color="#666633" backgroundColor="#cccccc"/>

      </mx:Application>

      best regards
      Keith
        • 1. Re: XML displaying
          Gregory Lafrance Level 6
          I got this to work. Could be how you are accessing data in the for each construct.
          -------------------------------- data\cata.xml ------------------------------------
          <?xml version="1.0"?>
          <products>
          <product>
          <name>Table</name>
          <price>10.00</price>
          </product>
          <product>
          <name>Chair</name>
          <price>20.00</price>
          </product>
          <product>
          <name>Tablecloth</name>
          <price>30.00</price>
          </product>
          </products>
          ------------------------------------ Test.mxml ------------------------------------
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;

          [Bindable]
          private var Phones:ArrayCollection = new ArrayCollection;

          private function dotQuery():void{
          for each(var p:Number in cata.product.price)
          Phones.addItem(p);
          }
          ]]>
          </mx:Script>
          <mx:XML id="cata" source="data/cata.xml"/>
          <mx:List dataProvider="{Phones}" creationComplete="dotQuery()"
          top="20" width="75%" horizontalCenter="0" fontFamily="Arial"
          color="#666633" backgroundColor="#cccccc"/>
          </mx:Application>

          • 2. Re: XML displaying
            Krellee Level 1
            Thanks for the reply Greg i'll you exsample a go