View Full Version : HTML markup from XML to a field & font issues
My client wants to change the font size, color and face of an app using HTML markup in XML.
How do I properly escape the text to pull this off?
Also included in my example .lzx is an attempt at change the font size after instantiation. If you click the text it should change the font size, instead the line size is changed and the font size remains the same.
Any ideas appreciated. :)
antun
01-15-2004, 02:54 PM
Changing font-size at run-time is fairly tricky. See this thread for more on that:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=515&highlight=font+size
As for escaping, have you tried using the unescaped < and > in a method that's escaped with CDATA tags?
-Antun
<canvas>
<dataset src="http://sports.espn.go.com/espn/rss/nba/news"
type="http" request="true"
name="nba" />
<view datapath="nba:/rss/channel/item">
<method event="ondata"><![CDATA[
var ptr=this.datapath.dupePointer();
ptr.setXpath('description')
var str=ptr.getnodetext();
debug.write('str1'+str)
this.tex1.setText(str)
str.replace("</*[^>]*>","");
debug.write('str2'+str)
this.tex2.setText(str);
]]>
</method>
<text name="tex1" multiline="true"/>
<text name="tex2" multiline="true"/>
</view>
<simplelayout axis="y"/>
</canvas>
When I try to print text from a rss feed containing html markup such as <p> </p> <b> </b> and <br/> I can neither remve the markup nor print the text with its markup.
I also tried to LztexT.escape(str) , couldn't make it work as I wish.
Any Idea??
antun
06-09-2004, 08:54 AM
When I tried your example with the debugger on, I got:
unknown host for http://sports.espn.go.com/espn/rss/nba/news: sports.espn.go.com
Do you see this too? It's possible that this is a deeper issue.
In general, if you're setting XML data with formatting, then the bold and italic fonts will not be included in your app by default (they'll get included if you declare some bold or italic text, but not if that text is set dynamically).
You can include them yourself. See the code for the googleblox app on mylaszlo; that includes the smaller verity9 fonts.
http://www.mylaszlo.com/lps-2.1.2/lz-utils/viewer/viewer.jsp?file=/antun/googleblox/googleblox.lzx
-Antun
http://sports.espn.go.com/espn/rss/nba/news
works fine... Maybe the server was down when You tried?
I 'll look at your google app thanks.
antun
06-09-2004, 09:30 AM
http://sports.espn.go.com/espn/rss/nba/news
works fine... Maybe the server was down when You tried?
No, the ESPN server was definitely working when I tried, because I could browse to the above URL. What I mean is there could be an issue in the LPS. If you run the code you posted with the debugger on, do you get anything in the debugger at all?
-Antun
well
<canvas height="1000" width="1000">
<font name="vera">
<face style="plain" src="verity/verity9.ttf"/>
<face style="bold" src="verity/verity9bold.ttf"/>
<face style="italic" src="verity/verity9italic.ttf"/>
</font>
<dataset src="http://sports.espn.go.com/espn/rss/nba/news" type="http" request="true" name="nba" />
<view height="1000" width="200" clip="false"> <view width="200" height="100" datapath="nba:/rss/channel/item" clip="false">
<method event="ondata"><![CDATA[
var ptr=this.datapath.dupePointer();
ptr.setXpath('description')
var str=ptr.getnodetext();
debug.write('str1'+str)
this.tex1.setText(str)
]]>
</method>
<text name="tex1" multiline="true" font="vera" width="50" />
</view>
<simplelayout axis="y"/></view>
</canvas>
I have a very selective
layout: only the headers
EDIT:
I mean I should the element i Try to print is like this:
<description>
<p> <b> A text that shold be in bold </b></p> a summary of an article.
</description>
with the above code, I can see all the contents of the tag description in the debugger so I receive it ,
but only "A text that should be in bold" appears on my screen (in bold) but the remaining text ("a summary of an article") is not there.
larryb
06-03-2005, 07:57 AM
I'm having a similar problem. I was making a rudimentary RSS reader as an intro to coding with Laszlo, but have gotten hung up on this important detail.
I have an RSS feed in which the description element is enclosed within CDATA tags. But when my .lzo app displays the text, any tags are gone and have been replaced by carriage returns (making the output appear rather messy).
The article at http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=1034 seems to indicate that with the CDATA tags this should work, but it does not.
I even tried adding an additional CDATA, in case that was necessary:
<canvas debug="true">
<dataset name="dset"
type="http"
request="true"
src="http://www.emediacommunications.biz/blog/index.rss"/>
<simplelayout axis="y"/>
<view width="200" datapath="dset:/rss/channel/item" ondata="processDesc()">
<method name="processDesc">
var descNode=this.datapath.dupePointer();
descNode.setXpath('description')
var rawtext=DescNode.getNodeText();
var newtext="<![CDATA["+rawtext+"]]>";
descNode.setNodeText( newtext );
Debug.write(descNode.serialize());
</method>
<simplelayout axis="y"/>
<text multiline="true" fontstyle="bold" datapath="title/text()" width="400"/>
<text multiline="true" datapath="description/text()" x="10" width="400"/>
<text multiline="true" datapath="link/text()" x="10" width="400"/>
</view>
</canvas>
johnny
07-21-2005, 03:25 PM
is is possible to do this with no CDATA wrapping the HTML tags? Basically, I want to retrieve xml data with nested html tags.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.