导入XML时消除段落之间的额外空间

时间:2012-02-27 21:46:36

标签: xml actionscript-3 actionscript htmltext

使用以下代码,我将数据从xml文件推送到经典动态文本框,该文本框配置为将文本呈现为html。由于某些原因,段落之间存在大量的空白区域。我不知道它为什么会存在,因为我已经将它设置为忽略空格。我怎么能摆脱它?

package  {

    import flash.display.*;
    import flash.events.*;
    import flash.net.*;

    public class Blog extends MovieClip {

        var rssLoader:URLLoader = new URLLoader();
        var rssURL:URLRequest = new URLRequest("http://www.woot.com/blog/rss.aspx");
        var rssXML:XML = new XML();

    public function Blog() {
        //Load RSS file
        rssLoader.addEventListener(Event.COMPLETE, blogBuilder);
        rssLoader.load(rssURL);
        rssXML.ignoreWhitespace = true;
    }

    public function blogBuilder(e:Event):void {
        rssXML = XML(rssLoader.data);

        //Adds data to blog
        titleBox.text = rssXML.channel.item[0].title;
        dateBox.text = rssXML.channel.item[0].pubDate;
        textBox.htmlText = rssXML.channel.item[0].description;
    }
}

1 个答案:

答案 0 :(得分:1)

试试这个:

rssXML = XML(rssLoader.data);
rssXML.ignoreWhite = true;
titleBox.condenseWhite = true;
dateBox.condenseWhite = true;
textBox.condenseWhite = true;