4 Replies Latest reply on Jul 10, 2007 11:30 AM by Newsgroup_User

    XML will not load no matter what

    Kai001
      I've recently been trying to use the TileList and Repeater to make an array of buttons with labels loaded from an xml file. I couldn't do it manually, so I used the example from the help file which will not work either.

      Code:
      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

      <mx:Model id="catalog" source="Catalog.xml"/>
      <mx:ArrayCollection id="myAC" source="{catalog.products.product}"/>

      <mx:Repeater id="r" dataProvider="{myAC}">
      <mx:RadioButton id="Radio" label="{r.currentItem.name}" width="150"/>
      </mx:Repeater>
      </mx:Application>

      XML File:
      <?xml version="1.0"?>
      <products>
      <product>
      <name>Name</name>
      <price>Price</price>
      <freeship>Free Shipping?</freeship>
      </product>
      <product>
      <name>Whirlygig</name>
      <price>5</price>
      <freeship>false</freeship>
      </product>
      <product>
      <name>Tilty Thingy</name>
      <price>15</price>
      <freeship>true</freeship>
      </product>
      <product>
      <name>Really Big Blocks</name>
      <price>25</price>
      <freeship>true</freeship>
      </product>
      </products>

      It simply exports and does not show anything in the browser. Why can't I make a dynamic TileList even from an example? I've made sure that the Catalog.xml is in the right directory.

      Any help is greatly appreciated! :D
        • 2. Re: XML will not load no matter what
          Kai001 Level 1
          bump

          I could still use this help.. :)
          • 3. Re: XML will not load no matter what
            Level 7
            Kai001 wrote:
            > I've recently been trying to use the TileList and Repeater to make an array of
            > buttons with labels loaded from an xml file. I couldn't do it manually, so I
            > used the example from the help file which will not work either.
            >
            > Code:
            > <?xml version="1.0"?>
            > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
            >
            > <mx:Model id="catalog" source="Catalog.xml"/>
            > <mx:ArrayCollection id="myAC" source="{catalog.products.product}"/>
            >
            > <mx:Repeater id="r" dataProvider="{myAC}">
            > <mx:RadioButton id="Radio" label="{r.currentItem.name}" width="150"/>
            > </mx:Repeater>
            > </mx:Application>
            >
            > XML File:
            > <?xml version="1.0"?>
            > <products>
            > <product>
            > <name>Name</name>
            > <price>Price</price>
            > <freeship>Free Shipping?</freeship>
            > </product>
            > <product>
            > <name>Whirlygig</name>
            > <price>5</price>
            > <freeship>false</freeship>
            > </product>
            > <product>
            > <name>Tilty Thingy</name>
            > <price>15</price>
            > <freeship>true</freeship>
            > </product>
            > <product>
            > <name>Really Big Blocks</name>
            > <price>25</price>
            > <freeship>true</freeship>
            > </product>
            > </products>
            >
            > It simply exports and does not show anything in the browser. Why can't I make
            > a dynamic TileList even from an example? I've made sure that the Catalog.xml is
            > in the right directory.
            >
            > Any help is greatly appreciated! :D
            >

            Do you not need to Specify an external source? I'm taking this from
            page 1006-1007 in "Developer's Guide."

            ---------

            Specifying an external source for an <mx:Model> tag or <mx:XML> tag

            You can specify an external source for an <mx:Model> or <mx:XML> tag in
            a source property. Separating the content of a model from the MXML that
            defines the user interface improves the maintainability and reusability
            of an application. Adobe recommends this way of adding static XML
            content to a Flex application.

            The external source file can contain static data and data binding
            expressions, just like a model defined in the body of the <mx:Model> or
            <mx:XML> tag. The file referenced in a source property resides on the
            server and not on the client machine. The compiler reads the source
            value and compiles the source into the application; the source value is
            not read at run time. To retrieve XML data at run time, you can use the
            <mx:HTTPService> tag; for more information, see Using RPC Components.

            Using <mx:Model> and <mx:XML> tags with external sources is an easy way
            to reuse data model structures and data binding expressions. You can
            also use them to prepopulate user interface controls with static data by
            binding data from the model elements into the user interface controls.

            The source property accepts the names of files relative to the current
            web application directory, as well as URLs with HTTP:// prefixes. In the
            following example, the content of the myEmployee1 data model is an XML
            file named content.xml in the local web application directory. The
            content of the myEmployee2 data model is a fictional HTTP URL that
            returns XML.

            <mx:Model source="employees.xml" id="employee1"/>

            <mx:Model source=" http://www.somesitel.com/employees.xml" id="employee2"/>

            The source file must be a valid XML document with a single root node.
            The following example shows an XML file that could be used as the source
            of the <mx:Model source="employees.xml" id="Model1"/> tag. <
            • 4. Re: XML will not load no matter what
              Level 7

              Never mind, I now see that in your code.


              Have you tried the ObjectUtil.toString() component to debug that you
              getting what you think you are getting>