问题
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