1 Reply Latest reply on Jul 3, 2013 5:45 PM by wizbowes

    Trouble loading an xml file - claims not to be terminated correctly

    wizbowes Level 1

      I'm trying to load some data in an xml file to create a tree view.  Before that I created this code with hardcoded xml definition which works fine and creates my treeview:


      <?xml version="1.0" encoding="utf-8"?>

      <csxs:CSExtension xmlns:fx="http://ns.adobe.com/mxml/2009"








                                    import com.adobe.csxs.core.CSInterface;




                                    private var hostName:String = HostObject.mainExtension;



                                    public function appComplete():void{

                                              CSInterface.instance.autoThemeColorChange = true;



                                    import mx.collections.ICollectionView;

                                    import mx.events.ListEvent;


                                    private function tree_itemClick(evt:ListEvent):void {

                                              var item:Object = Tree(evt.currentTarget).selectedItem;

                                              if (tree.dataDescriptor.isBranch(item)) {

                                                        tree.expandItem(item, !tree.isItemOpen(item), true);




                                    private function tree_labelFunc(item:XML):String {

                                              var children:ICollectionView;

                                              var suffix:String = "";

                                              if (tree.dataDescriptor.isBranch(item)) {

                                                        children = tree.dataDescriptor.getChildren(item);

                                                        suffix = " (" + children.length + ")";


                                              return item[tree.labelField] + suffix;







                          <fx:XML id="myXml">


                                              <folder label="One">

                                                        <folder label="One.A">

                                                                  <item label="One.A.1" />

                                                                  <item label="One.A.2" />

                                                                  <item label="One.A.3" />

                                                                  <item label="One.A.4" />

                                                                  <item label="One.A.5" />


                                                        <item label="One.1" />

                                                        <item label="One.2" />


                                              <folder label="Two">

                                                        <item label="Two.1" />

                                                        <folder label="Two.A">

                                                                  <item label="Two.A.1" />

                                                                  <item label="Two.A.2" />







                <mx:Tree id="tree"







                                     itemClick="tree_itemClick(event);" />




      So that works.  Now I've created an xml file to replace the hardcoded xml.  The file looks like this:


      <?xml version="1.0" encoding="UTF-8"?>


                <folder label="One">

                          <folder label="One.A">

                                    <item label="1One.A.1" />

                                    <item label="1One.A.2" />

                                    <item label="1One.A.3" />

                                    <item label="1One.A.4" />

                                    <item label="1One.A.5" />


                          <item label="1One.1" />

                          <item label="1One.2" />


                <folder label="Two">

                          <item label="Two.1" />

                          <folder label="Two.A">

                                    <item label="2Two.A.1" />

                                    <item label="2Two.A.2" />






      And I've replaced the xml creation in the code with:



      <fx:XML id="myXml" source="/Users/rob/Desktop/myXml.xml" />



      However when I try to run this it fails, giving me an error:



      Main Thread (Suspended: TypeError: Error #1085: The element type "root" must be terminated by the matching end-tag "</root>".)



      But my xml file IS terminated correctly.  Any ideas?


      Running Adobe Extension Builder 2.1 on Mac Snowleopard.