[flexcoders] Loading Unicode values from XML and viewing in Flex components as HTML

2006-08-09 Thread Michael Ritchie
In a recent project, I wanted to load the Unicode values for special
characters from an external XML file. I wanted these values to show up
in a label or text box using something like label.htmlText =
\ul00A9, which would produce the copyright symbol.  However, when I
loaded the values from a simple XML node, the resulting label showed
the literal value\ul00A9 instead of the copyright symbol.  I created
a test application and found that local XML vars work and local
Unicode strings work, but not loaded Unicode values from XML. I have
sample URL for my test application (right-click view source) and the 
code below:

URL: http://thanksmister.com/xmlunicode/index.html  

Flex Code:

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute creationComplete=charXML.send();  height=210
width=393 viewSourceURL=srcview/index.html
  mx:Script
![CDATA[
private function serviceListener():void
{
  var tempXML:XMLList =  charXML.lastResult.character as XMLList;

  var localXML:XML = 
character
data\u00A9/data
labelInverted Exclamation Mark/label
/character;

  test1.htmlText = localXML.data;
  test2.htmlText = \u00A9;  // string 
  test3.htmlText = tempXML.data;

 }
]]
/mx:Script

mx:HTTPService 
url=data/test.xml 
  id=charXML
  resultFormat=e4x
  result=serviceListener() /

mx:Canvas width=291 height=164 backgroundColor=#ff x=51
y=19
  mx:Label text=Copyright Local XML: x=10 y=10/
  mx:Label text= x=201 y=10 id=test1/
  mx:Label text=Copyright Text String: x=10 y=59/
  mx:Label text= x=201 y=59 id=test2/
  mx:Label text=Copyright Imported XML: x=10 y=117/
  mx:Label text= x=201 y=117 id=test3/
/mx:Canvas
/mx:Application


External XML file:

?xml version=1.0 encoding=UTF-8?
specialChars
  character
data\u00A9/data
labelCopyright sign/label
  /character
/specialChars


Thanks, Michael 






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] Loading Unicode values from XML and viewing in Flex components as HTML

2006-08-09 Thread Gordon Smith












\u00A9 is AS syntax that only means
something inside of an AS string literal.



In an XML literal, you have to use XML
entity syntax, which I believe would be data#x00A9;/data.



- Gordon











From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie
Sent: Wednesday, August 09, 2006
1:03 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Loading
Unicode values from XML and viewing in Flex components as HTML











In a recent project, I wanted to load the Unicode
values for special
characters from an external XML file. I wanted these values to show up
in a label or text box using something like label.htmlText =
\ul00A9, which would produce the copyright symbol. However, when I
loaded the values from a simple XML node, the resulting label showed
the literal value\ul00A9 instead of the copyright symbol. I created
a test application and found that local XML vars work and local
Unicode strings work, but not loaded Unicode values from XML. I have
sample URL for my test application (right-click view source) and the 
code below:

URL: http://thanksmister.com/xmlunicode/index.html


Flex Code:

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
layout=absolute creationComplete=charXML.send();
height=210
width=393 viewSourceURL=srcview/index.html
mx:Script
![CDATA[
private function serviceListener():void
{
var tempXML:XMLList = charXML.lastResult.character as XMLList;

var localXML:XML = 
character
data\u00A9/data
labelInverted Exclamation Mark/label
/character;

test1.htmlText = localXML.data;
test2.htmlText = \u00A9; // string 
test3.htmlText = tempXML.data;

}
]]
/mx:Script

mx:HTTPService 
url="">xml 
id=charXML
resultFormat=e4x 
result=serviceListener() /

mx:Canvas width=291 height=164 backgroundColor=#ff
x=51
y=19
mx:Label text=Copyright Local XML: x=10
y=10/
mx:Label text= x=201 y=10
id=test1/
mx:Label text=Copyright Text String: x=10
y=59/
mx:Label text= x=201 y=59
id=test2/
mx:Label text=Copyright Imported XML: x=10
y=117/
mx:Label text= x=201 y=117
id=test3/
/mx:Canvas
/mx:Application

External XML file:

?xml version=1.0 encoding=UTF-8?
specialChars
character
data\u00A9/data
labelCopyright sign/label
/character
/specialChars

Thanks, Michael 






__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___