displaying HTML Text in Tree Data

Hi Folks,

I was trying to display an html Text in the data field of a Tree node.

See this line
<folder label="1. General" data="Information about the resource or content aggregation as a whole.">

When I put an HTML text in the data section, I get an error saying < is not a valid

How do I put html text in the data field of a tree node

thanks

RG
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
 <mx:Script>
      <![CDATA[
         import flash.events.*;
         import mx.events.*;
         import mx.controls.*;
		
			
         private function changeEvt(event:Event):void {
            var theData:String = ""
            if (event.currentTarget.selectedItem.@data) {
               theData =  event.currentTarget.selectedItem.@data;
            }
            textSpace.htmlText = theData;
         }

   ]]>
   </mx:Script>
   <mx:Tree id="tree1" labelField="@label" showRoot="true" width="450" height="600"
        dragEnabled="true"
        dropEnabled="true">
      <mx:XMLListCollection id="Taxonomy">
         <mx:XMLList>
            <folder label="1. General" data="Information about the resource or content aggregation as a whole.">
               <folder label="1.1 Identifier (Owner)"/>
               <folder label="1.2 Title"/>
               <folder label="1.3 Language"/>
               <folder label="1.4 Description"/>
               <folder label="1.5 Keyword"/>
               <folder label="1.6 Coverage"/>
               <folder label="1.7 Structure"/>
               <folder label="1.8 Aggregation Level"/>
               <folder label="1.9 Accessibility"/>
               
               
               
               <folder label="Personal Folder">
                  <Pfolder label="Business" />
                  <Pfolder label="Demo" /> 
                     <Pfolder label="Personal" isBranch="true" /> 
                     <Pfolder label="Saved Mail" /> 
                  </folder>
                  <folder label="Sent" />
                  <folder label="Trash" />
            </folder>
         </mx:XMLList>
      </mx:XMLListCollection>
   </mx:Tree>
</mx:Application>

Open in new window

rgarimellaAsked:
Who is Participating?
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Why don't you directly use tree1 by id as I am showing in the alert box, or else you are suppose to get the current target to tree and then get the selectedItem and its data.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
	<mx:Script>
		<![CDATA[
			import flash.events.*;
			import mx.events.*;
			import mx.controls.*;
			
			
			private function changeEvt(event:Event):void {
				var theData:String = ""
				/*if (event.currentTarget.selectedItem.@data) {
					theData =  event.currentTarget.selectedItem.@data;
				}*/
				Alert.show(tree1.selectedItem.@data);
			}
			
		]]>
	</mx:Script>
	<mx:Tree id="tree1" labelField="@label" showRoot="true" width="450" height="600"
			 dragEnabled="true"
			 dropEnabled="true" change="changeEvt(event)">
		<mx:XMLListCollection id="Taxonomy">
			<mx:XMLList>
				<folder label="1. General" data="Information about the resource or content aggregation as a whole.">
					<folder label="1.1 Identifier (Owner)"/>
					<folder label="1.2 Title"/>
					<folder label="1.3 Language"/>
					<folder label="1.4 Description"/>
					<folder label="1.5 Keyword"/>
					<folder label="1.6 Coverage"/>
					<folder label="1.7 Structure"/>
					<folder label="1.8 Aggregation Level"/>
					<folder label="1.9 Accessibility"/>
					<folder label="Personal Folder">
						<Pfolder label="Business" />
						<Pfolder label="Demo" /> 
						<Pfolder label="Personal" isBranch="true" /> 
						<Pfolder label="Saved Mail" /> 
					</folder>
					<folder label="Sent" />
					<folder label="Trash" />
				</folder>
			</mx:XMLList>
		</mx:XMLListCollection>
	</mx:Tree>
</mx:Application>

Open in new window

0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
I am not sure if I understood your question completely but you have to replace all < with < and then try.
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
oh "&lt ;" EE  converted my less then encoding to "<"
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
rgarimellaAuthor Commented:
Ya I tried "&lt ;" this does not work. I am trying to display html text in the data tag

This line

<folder label="1. General" data="Information about the resource or content aggregation as a whole.">
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
I am trying to use your exact code, what is "textSpace" in that MXML its missing.
0
 
rgarimellaAuthor Commented:
The solution that I want is not to just display the data label, but putting html text inside the data label.

Ignore textspace. Some debugging
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
wait I told u clearly that you question is not 100% clear, if you want to put in any html data inside a XML first of all you need to use a CDATA tag

http://www.w3schools.com/xml/xml_cdata.asp

and where exactly do you want to display that html??
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
by the way you can't have a CDATA as part of a XML attribute instead you need to have it as an element in your XML.
0
 
rgarimellaAuthor Commented:
not the complete solution that I was looking
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.