6 Replies Latest reply on Jul 17, 2007 2:13 PM by Kai001

    Convert HTTPService to XML

    Kai001
      I simply want to put elements into my tree object through a properly formatted XML file. I've done this with the XML tag but I want it so that it will update on every browser refresh. I thought the best way would be to use an httpservice. How would I do this? :D

      Any help is greatly appreciated! :D
        • 1. Re: Convert HTTPService to XML
          peterent Level 2
          Create a file with your data. Let's say you call it myconfig.xml and you put it into the same directory as your SWF. You can then load it using HTTPService:

          <mx:HTTPService id="srv" url="myconfig.xml" resultFormat="xml" />

          Then you can trigger the load with srv.send() and bind the Tree to srv.lastResult. yournodehere.
          • 2. Re: Convert HTTPService to XML
            ntsiii Level 3
            Be alert for the caching problem. The browser will often cache your data. One common workaround is to append some random string to the url.
            Tracy
            • 3. Re: Convert HTTPService to XML
              Kai001 Level 1
              I did exactly what you said. Except the tree is blank after export. My XML file IS in the right place.

              My MXML:
              <?xml version="1.0"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="ac.send();" layout="absolute" horizontalScrollPolicy="off" verticalScrollPolicy="off" width="151">
              <mx:HTTPService id="ac" url="test.xml" resultFormat="xml" useProxy="false"/>
              <mx:Tree width="100%" height="100%" dataProvider="{ac.lastResult.folder[0]}" labelField="@label
              </mx:Application>

              My XML:
              <folder label="Mail">
              <folder label="Test"/>
              <folder label="Personal Folder">
              <Pfolder label="Business" />
              <Pfolder label="Demo" />
              <Pfolder label="Personal" isBranch="true" />
              <Pfolder label="Saved Mail" /></folder>
              <folder label="Sent" /> <folder label="Trash" />
              </folder>
              <folder label="MailMan">
              </folder>

              Thanks for the help so far its very appreciated! :D
              • 4. Re: Convert HTTPService to XML
                Level 7
                Hi Tracy

                I'm trying to send you an email but it keeps bouncing.

                I'm wondering if you have time and are interested in a small project. If so,
                can you drop me a quick email so I have the correct email for ya. I'll reply
                to that.

                TY

                Bill
                bill at datapacks dot com


                "ntsiii" <tspratt@lariatinc.com> wrote in message
                news:f7h72o$cg0$1@forums.macromedia.com...
                > Be alert for the caching problem. The browser will often cache your data.
                > One common workaround is to append some random string to the url.
                > Tracy


                • 5. Re: Convert HTTPService to XML
                  peterent Level 2
                  Based on the XML you've sent, you have a single root <folder> which will be event.lastResult in the binding. You could try this:

                  <mx:Tree dataProvider="{XML(event.lastResult)}" labelField="@label" ... >

                  You need to have @label as the field name because the default is just label which means your XML would have things like:

                  <folder><label>One</label></folder> using @ indicates that you are using an attribute.
                  • 6. Re: Convert HTTPService to XML
                    Kai001 Level 1
                    Alright, it works now. 8-)

                    Thanks for the help! :D