1 Reply Latest reply on Jan 25, 2010 3:10 PM by CMcM00

    Trouble with XML-related data types


      Hi -


      I'm having a lot of trouble getting data out of a XMLListCollection object and don't understand since it seems rather unintuitive.


      Inside of an ItemRenderer, I have a block of XML in my 'data' property.


      If I look at this in the debugger, it looks something like this:





      Ok. So in my itemrenderer, I can put in a trace that looks like this:




      Which prints this in the console window:




      First off, I find it rather unintuitive that you access this by data.Links instead of data.Record.Links, but whatever - at least I got this far.


      Now, lets say I wanted to test whether Links had any children. Maybe this record has no links, maybe it has 10.



      None of these constructs work:


      var links:XMLList = data.Links.children() as XMLList;
      var links:XMLList = data.Links as XMLList;
      var links:Object = data.Links as Object;
      var links:Class = data.Links as Class;
      var links:* = data.Links;


      What's the magic trick necessary to navigate this data object?

      I want to iterate over all links in the Record and create LinkButton objects for each of them, then add them to my object with addChild();


      I can't even figure out the syntax to test for the number of links in the <Links> section.



        • 1. Re: Trouble with XML-related data types
          CMcM00 Level 1

          Ok looks like this works


          var links:XMLList = new XMLList(data.Links.children());


          Not sure why you have to create it with new().  I would have thought 'links' would just be a pointer to that data instead of allocating new memory for a copy.