Actionscript3 E4X XML 和 CSS:我真的必须使用 CDATA 吗?
当在 XML 内部使用 CSS 时,例如
<span class="IwuvAS3"></span>
在 Flash 中解析时,如果我不使用如下所示的 CDATA:
<![CDATA[<span class="IwuvAS3"></span>]]>
那么解析后的数据会为每个“<”下降一行。 它看到的字符。
将数据解析为单行文本字段时,没有显示任何内容,因为它实际上是在一行中。 当我将它包装在 CDATA
中时,它就工作得很好。 我玩过prettyIndent
,据我了解ignoreWhite
默认情况下是true。
有没有一种方法可以在不使用 CDATA
的情况下解析数据并保持隐含的换行符?
编辑1 (10/10/08):谢谢,但我实际上正在寻找一个函数或方法。 转义每一个都比使用 CDATA 麻烦得多。 我不想使用 CDATA 的唯一原因是我被教导要远离它。 如果 ActionScript 有一个与 E4X XML 处理相关的方法,可以消除将 XML 包装在 CDATA 中的要求,我很想知道它。
编辑 1 (10/15/08):谢谢菲利普! 我从来没有想到 Flash 中的 HTML 格式会被视为空白。 答案是
textField.condenseWhite = true;
<3AS3
When working with CSS inside of XML such as
<span class="IwuvAS3"></span>
when parsed in flash, if I don't use CDATA like the following:
<![CDATA[<span class="IwuvAS3"></span>]]>
then the parsed data drops down a line for every "<" character it sees.
When parsing the data into a single-line text field, nothing was shown because it was actually down a line. Soon as I wrap it inside of CDATA
it works great. I have played with prettyIndent
, and as I understand ignoreWhite
is true by default.
Is there a way to parse the data without the use of CDATA
and keep the implied line breaks out?
EDIT 1 (10/10/08): Thank you, but I am actually looking for a Function or Method. Escaping each is much more cumbersome than using CDATA. The only reason I don't want to use CDATA is that I was taught to stay clear of it. If ActionScript has a method associated to E4X XML handling that will remove the requirement to wrap my XML in CDATA, I would love to know about it.
EDIT 1 (10/15/08): Thanks Philippe! I never would have thought that HTML formatting in Flash is treated as whitespace. The answer was
textField.condenseWhite = true;
<3AS3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 TextField 的 condenseWhite 属性设置为 true - 因此仅 condenseWhite 。 br>> 标签将生成换行符。
Set the TextField's condenseWhite property to true - so only < br/> tags will generate linebreaks.
你可以逃避“<” 字符(以及 &、"、>、' 等)作为实体。
You could escape the "<" characters (and &, ", >, ', among others) as entities instead.