4 Replies Latest reply on Jan 17, 2007 9:21 AM by cnizzle

    accessing HTTPService xml attributes

    cnizzle
      i have an HTTPService isntalled which gets an xml document, something like this
      <item>
      <doc name="x" url="htttp://www.yyy.com" />
      <doc name="x" url="htttp://www.yyy.com" />
      <doc name="x" url="htttp://www.yyy.com" />
      </item>
      i want to display each doc tag in a list component with attribute -->name<--, now as far as it goes i can only get the list
      to display: [object Object] and this is what my dataProvider for list components looks like:
      dataProvider="{service.lastResult.item.doc}" i have trid every single trick but i cannnot get the list to show the name attribute of each of those tags or even the url tag. what is the solution to this?
        • 1. Re: accessing HTTPService xml attributes
          iquaaani
          Have you tried something like:

          <mx:HTTPService
          id="yourXmlFile"
          url="yourXmlFile.xml"
          showBusyCursor="true"
          resultFormat="e4x"
          />
          <mx:HTTPService

          dataProvider="{yourXmlFile.lastResult.doc.*}
          dataProvider="{yourXmlFile.lastResult.doc.@name}
          dataProvider="{yourXmlFile.lastResult.doc.@url}
          • 2. Re: accessing HTTPService xml attributes
            cnizzle Level 1
            i just treid it now and no result.
            • 3. Re: accessing HTTPService xml attributes
              ntsiii Level 3
              iquaaani's approach is what I would also suggest, especially resultFormat="e4x". However, I don't advise binding directly to lastResult because it is hard to debug. Instead, use a handler function called by the result event.

              In that handler, do something like:
              var xmlREsult:XML = XML(event.result);
              trace(xmlResult.toXMLString());

              This will show you exactly what your result xml looks like, so you will know how to write the access expression.

              See this for more info on using XML:
              http://livedocs.macromedia.com/flex/2/docs/00001910.html

              Tracy


              Tracy
              • 4. accessing HTTPService xml attributes
                cnizzle Level 1
                thank you, actually i used some knowledge of action script to solve this problem, i realized that you can access each node by e.g. source.lastResult.item.doc[0]['name'], since i cant put that in the provider i made a function which recieves the object, calculates the length and places them into an array and the as function returns that array in ({label:x, data:y}) format, what you would do in flash, so the dataProvider was "{getDoc(source.lastResult.item.doc)}" and since the result is an array, worked like a charm, no need for Thumbnails and that.