9 Replies Latest reply on Feb 4, 2008 8:54 PM by Sreenivas R

    Dynamic Update on XML tree

    2JZ
      I have attached a XML to a tree control. I want it to update itself when a user makes changes on the XML file. How do I do that?

      Since the tree control has to specify a file name instead of a string variable of a file name, I cannot use the HTTPService with a dummy variable in url link as below:

      <mx:HTTPService id="MainSrv" url="{MarketViewFilePath}">

      with action script line:
      MainSrv.url = MarketViewFilePath + "?dummy=" + new Date();

      Please help.
        • 1. Re: Dynamic Update on XML tree
          Sreenivas R Adobe Employee
          You need to use a Timer to periodically load the XML file using the HTTP service.

          I am unable to understand the second part of the question.
          • 2. Re: Dynamic Update on XML tree
            ntsiii Level 3
            Yes, the Tree has nothing to do at all with files. What is the problem?

            Tracy
            • 3. Re: Dynamic Update on XML tree
              2JZ Level 1
              The way I load the xml is like this:
              &lt;mx: XML source=&quot;xml/file1.xml&quot;/&gt;

              That's why I have the problem. Maybe I should use the HTTP instead. Thanks.
              • 4. Re: Dynamic Update on XML tree
                ntsiii Level 3
                Correct. Using source=&quot;&quot; is a compile-time activity. You need to use HTTPService to be able to do it at run-time.

                Tracy
                • 5. Re: Dynamic Update on XML tree
                  2JZ Level 1
                  My XML file has following structure:
                  List
                  --Regions
                  ...L---Markets
                  .........L--Areas
                  .............L--Dates

                  public var TreeXML:XML;
                  private function TreeResultHandler(event:ResultEvent):void
                  {
                  TreeXML = new XML( event.result.list.source );
                  }

                  My code return an empty string on TreeXML. :(
                  Can you guys show me how to load xml file through HTTPService?
                  • 6. Re: Dynamic Update on XML tree
                    2JZ Level 1
                    This is what I have initially:

                    &lt;mx:XML id=&quot;TreeXML&quot; source=&quot;xml/MarketDashboard_Tree.xml&quot;/&gt;
                    &lt;mx:XMLListCollection id=&quot;TreeXMLList&quot; source=&quot;{TreeXML.region}&quot;/&gt;

                    With the XMLListCollection, I can make the tree control to scroll to the highlighted item in the tree. The XMLListCollection can only be created at compile time. Meaning that has to be static. If I use the HTTPService, is it possible to create a XMLListCollection?
                    • 7. Dynamic Update on XML tree
                      2JZ Level 1
                      I got the HTTPService to load the XML file.

                      Is there a way to create a XMLLIstCollection after loading the XML file? The reason is that I want to get this because I was using XMLListCollection's getItemIndex() to scroll the tree control to the selected node.
                      • 8. Dynamic Update on XML tree
                        chinna4all
                        i put some code here, with best of my knowledge, you can try once.
                        &lt;mx:HTTPService id=&amp;quot;e4xService&amp;quot;
                        url=&quot;assets/Tree.xml&quot;;
                        resultFormat=&quot;e4x&quot;
                        result=&quot;treeXMLHandler(event)&quot;&gt;
                        all the best
                        • 9. Dynamic Update on XML tree
                          Sreenivas R Adobe Employee
                          if your XML looks like this
                          list
                          ..........Regions
                          ...................Markets
                          ...........
                          .................../Markets
                          ......../Regions;
                          .../list

                          then you can create a XMLListCollection as follows

                          new XMLListCollection(event.result.Regions)

                          No need to speicify the root list tag.