How to get a node from xml not knowing its level in flex?

℡╲_俬逩灬. 提交于 2019-12-12 21:13:26

问题


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

I.e

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

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

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


回答1:


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).



来源:https://stackoverflow.com/questions/2396895/how-to-get-a-node-from-xml-not-knowing-its-level-in-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!