Flex Data Binding - Nodes or Attributes?
The last example showed one EASY way to drill down and access your data with Flex.
If you noticed, all of the "data" in my XML file was stored in the attributes of a node, rather than in the child nodes. All of the examples I have seen from Macromedia show the XML formatted with the data contained in child nodes.
What is interesting and somewhat disconcerting is that your XML data can be formatted either way and you do not need to make any changes to your code.
So what happens if you have an attribute name with some data and a child node of the same name? In this case the attribute wins and takes precedence over the child node.
I took the "Drilling Down into Data" example and modified it to load one of three different XML files on button click. You can view it below and see how each XML file is used.
View Example
View Source MXML
View Attribute XML
View Node XML
View Node XML with an Attribute
I find it confusing that you can use either type of XML without any changes to your code. I think it would make more sense if you used a "@" when you wanted to access an attribute rather than a node. This is how you access attributes with E4X in actionscript 3.
So:
mx:ComboBox x="25" y="60" width="190" id="locationSelector" labelField="title" dataProvider="{contentData.tourContent.mLocation}"
could be
mx:ComboBox x="25" y="60" width="190" id="locationSelector" labelField="@title" dataProvider="{contentData.tourContent.mLocation}"
Comments
Hi Adam, Your blog is interesting but not very helpful for me. Glad to see that you're not letting Andrea be the only one in the family with one. Take care. Mom
Posted by: Anonymous | December 1, 2005 09:39 PM
Hello, it's very good site too: butalbital free shipping , mexican butalbital http://lopnutmoiglaza.dipdns.org/butalbital/butalbital_free_shipping.html
Posted by: what is valium used to treat | January 29, 2006 08:39 PM