Reputation: 501
I have a tree in flex built from an XML document into an XMLlist
In the XML the tags are all different and have a bunch of attributes each, and are not consistent.
When I publish the file I want the name of the folders in the tree to be the tag. It is easy with attributes.. "@id" or something similar, but I can't find what it could be to use the tag itself.
Thanks
Upvotes: 0
Views: 990
Reputation: 16085
You'll have to use a custom label function to do that. Here's an example. Hope this helps.
<?xml version="1.0" encoding="utf-8"?>
<WindowedApplication xmlns="http://ns.adobe.com/mxml/2009">
<Script>
<![CDATA[
[Bindable]
public var xml:XML = <node1><node2a><node3><node4/></node3></node2a><node2b/></node1>;
public function myLabelFunction(item:Object):String {
var node:XML = XML(item);
var nodeName:QName = node.name();
return nodeName.localName;
}
]]>
</Script>
<Tree width="100%" dataProvider="{xml}" labelFunction="myLabelFunction"/>
</WindowedApplication>
Upvotes: 2