Consider this XML snippet with βnodesβ, which can have unlimited levels of subnode children.
I want to find the @type node attribute for any given subnode based on its @id attribute. For example, if I have identifier 9, then I want to return type = "foo" on top.
<xml> <node type="bar"> <subnode id="4"> <subnode id="5"/> </subnode> <subnode id="6"/> </node> <node type="foo"> <subnode id="7"> <subnode id="8"> <subnode id="9"/> </subnode> </subnode> <subnode id="10"/> </node> </xml>
E4X, which I came across, but which does not work:
xml.node.(subnode.(@id == '8')) .@type
I can understand why this is not working. What would be more reasonable is the following, but the syntax will not work (in AS3):
xml.node.(..subnode.(@id == '8')) .@type
How can I do that?
source share