actionscript-3 - 是否有另一种方法可以在没有 E4X 语法的情况下过滤 xml 元素?
问题描述
我正在尝试使用Jangaroo将一些旧的动作脚本代码(Flash 应用程序的一部分)编译为 JS 。Jangaroo 不支持 E4X 语法,并且在双点运算符..
或括号过滤器等方面失败a.(CONDITION)
。所以我需要使用普通的 ActionScript 重写这些代码部分。
对于双点运算符,我使用了方法descendants()
,但我找不到编写括号过滤器的替代方法。
这是我的原始代码:
B = xml..destination.(@id == someId)
我现在写了:
B = xml.descendants("destination").(@id == someId)
但我仍然想删除.(@id == someId)
.
我正在考虑类似的事情:
if (xml.descendants("destination").attribute("id") == someId)
{
B = xml.descendants("destination")
}
这可能吗?
解决方案
所以这就是我如何进行的。我没有测试过它的功能,但是编译器通过了它。
var destinations:XMLList = null;
for each (var elm in xml.descendants("destination") )
{
if ( elm.attribute("id") == someId )
{
destinations += elm;
}
}
推荐阅读
- sql-server - 如何更改 SSRS 中的部署凭据?
- java - 使用 http put 将值从 Angular 5 传递到 Java REST API,第 0:-1 行在输入处没有可行的替代方案
- wordpress - wordpress 简码包装
- java - Java JSONArray 对象返回 HTML 格式?
- ruby - Ruby 许多 HTTP 请求
- javascript - 从一个 php 文件中,我需要在相同的 isset 条件下将两个 ajax 变量传递给两个独立的 javascript 文件
- ionic-framework - 如何在 ionic 3 中修复此错误
- excel - 从单元格公式访问 ActiveX 文本框值
- java - 规则失败后从规则文件返回
- django - 如何在 django 表单中禁用表单输入字段的呈现