Hi all,

How come that XML comment nodes are not selectable when used in a
XMLListCollection that acts dataprovider to a Tree control? How would
you work around this the best way?

Thanks!

Nick

Example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
initialize="onInitialize()">

     <mx:Script>
         <![CDATA[

             import mx.collections.XMLListCollection;

             [Bindable]
             private var companyData:XMLListCollection;

             private function onInitialize():void
             {
                 XML.ignoreComments = false;
                 var company:XML = <list><dept
title="Finance"><!--Comment--><employee name="John H"/><employee
name="Sam K"/></dept></list>;
                 companyData = new XMLListCollection(company.dept)
             }

             private function treeLabel(item:Object):String
             {
                 var node:XML = XML(item);
                 if (node.nodeKind() == "comment")
                 {
                     return node.toString();
                 }
                 if( node.localName() == "dept")
                 {
                     return [EMAIL PROTECTED];
                 }
                 else
                 {
                     return [EMAIL PROTECTED];
                 }
             }

         ]]>
     </mx:Script>

     <mx:Tree id="tree" dataProvider="{companyData}"
labelFunction="treeLabel" height="200" width="200"/>

</mx:Application>


Reply via email to