如何从xml中获取节点而不知道它在flex中的级别? [英] How to get a node from xml not knowing its level in flex?

查看:20
本文介绍了如何从xml中获取节点而不知道它在flex中的级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,如何在要插入的女巫中获取节点:

My question is, that how can I get the node in witch I want to insert:

    <folder id="1">
          <folder id="4">
               <folder id="5"></folder>
          </folder>
    </folder>
    <folder id="2">
          <file id="4"/>
    </folder>
    <folder id="3">
    </folder>

我想获取 id = 4 的文件夹,但这可以在任何级别.

I want to get folder with id = 4, but that can be on any level.

如果文件夹不能相互包含,那就是这样 myNode = xml.folder.(@id == 4).

If folders couldn't contain one another than it would be like this myNode = xml.folder.(@id == 4).

推荐答案

使用 .. 运算符,它会查找所有具有给定名称的节点,无论它们有多深.例如 xml..folder将在您的 XML 中找到所有 节点.所以你要做的是 myNode = xml..folder.(@id == 4).

Use the .. operator, it looks for all the nodes with given name and it doesn't matter how deep they are. For example xml..folder will find all the <folder/> nodes in your XML. So what you're trying to do will be myNode = xml..folder.(@id == 4).

这篇关于如何从xml中获取节点而不知道它在flex中的级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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