如何根据以“something”开头的属性值选择 xml 元素在动作脚本3中
比如说,我有一个如下所示的 xml:
public static var keywords:XML = <keywords>
<tag key="html" type="tag"/>
<tag key="htmlNew" type="attr"/>
<tag key="head" type="attr"/>
<tag key="body" type="attr"/>
</keywords>;
我需要按属性值搜索此 xml。如果用户提供“html”输入,那么我需要返回
节点作为 XMLList。它是从通过 xml 属性进行类型搜索开始的。请任何人提供任何类型的解决方案或建议。对于直接属性匹配,我使用了以下代码:
var closeMatchList:XMLList = xml.tag.(@key == "html") as XMLList;
它仅返回
标签
这种解决方案可能吗?请任何人提供任何类型的解决方案。我被这个问题困扰了很长时间。提前致谢。
say, I have an xml like as follows:
public static var keywords:XML = <keywords>
<tag key="html" type="tag"/>
<tag key="htmlNew" type="attr"/>
<tag key="head" type="attr"/>
<tag key="body" type="attr"/>
</keywords>;
I need to search this xml by attribute value. If user provides input as "html" then I need to return both <tag key="html" type="tag"/> <tag key="htmlNew" type="attr"/>
node as XMLList. It kind of start with type searching by xml attribute. Please anybody provide any kind of solution or suggestion. for direct attribute matching I have used following code:
var closeMatchList:XMLList = xml.tag.(@key == "html") as XMLList;
It returns only <tag key="html" type="tag"/>
tag
Is this kind of solution is possible?? please anybody provide any kind of solution. I am stuck with this problem for long time. thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有第三方库,您也可以这样做:
Without third party libraries you could also do this:
ActionScript3 的 XPath 库 (xpath-as3) 可以轻松完成此操作。
使用该库的其他一些方法可以在此处。
There is an XPath library for ActionScript3 (xpath-as3) that can do this easily.
Some other ways to use the library can be seen over here.