Flex的字符串到HTML的解析与DOM [英] Flex String to HTML for parse with DOM

查看:158
本文介绍了Flex的字符串到HTML的解析与DOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串:

private str:String = '
<!DOCTYPE html>
<html>
<body>
<div>TEST</div>
<span id="t1">T1 Content</span>
<span class="t2">T2 Content</span>
</body>
</html>';

我要解析字符串。接下来,我通过对象,ID或类得到的innerHTML。

I want to parse the string. Next, I get innerHTMl via Object, ID or Class.

例如:

Objects: Body, Div, Span
IDs: t1
Classes: t2

在PHP中,这很容易。但我不能用Flex创建此版本。

In PHP with the class, it's easy. But I could not create this build with Flex.

感谢您的帮助......

Thanks for help...

推荐答案

将其转换为在AS3原生XML,然后使用E4X解析所需的信息:

Convert it to native XML in as3, then use e4x to parse the information required:

var xml:XML = XML(str);

//trace the content of any span with the id of "t1"
trace(xms..span.(attribute("id") == "t1"));

//trace the content of any span with the class t2
trace(xml..span.(attribute("class") == "t2"));

//trace the contents of the first div
trace(xml..div[0]);

更多关于E4X,这是一个很好的引物: http://www.senocular.com/flash/tutorials/as3withflashcs3/?page = 4

For more on e4x, this is a good primer: http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4

这篇关于Flex的字符串到HTML的解析与DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆