如何检索 xml 节点根/顶级父节点
您好,我如何在 ActionScript 中检索 xml 节点的顶级父节点?
<companies>
<company id="1" name="boo" level="1">
<company id="2" name="hoo" level="2">
<company id="3" name="ooo" level="3"/>
</company>
</company>
</companies>
提前致谢。
Hi how do i retrieve the top level parent of an xml node in actionscript please?
<companies>
<company id="1" name="boo" level="1">
<company id="2" name="hoo" level="2">
<company id="3" name="ooo" level="3"/>
</company>
</company>
</companies>
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑(最终):
我想我明白了您的问题:具有所选
company.(@level = 3)
company.(@level = 1) 节点是什么代码> 作为一个孩子。这也称为所选节点的“祖先”。 AS3 XML 没有强大的祖先语法,因此您必须手动向上执行。对于未知级别的养育,请使用类似于这篇文章讨论中的评论的循环。请注意,以下代码使用
id
属性进行搜索。这是因为所有id
在单个 XML 中必须是唯一的,因此您可以保证找到该 id。Edit (final):
I think I get what you are asking: what is the
company.(@level = 1)
node that has the selectedcompany.(@level = 3)
as a child. This is also known as an "ancestor" of the selected node. AS3 XML does not have a robust ancestor syntax, so you have to step upwards manually.For unknown levels of parenting, use a loop like the comments in this post discuss. Note that the following code uses the
id
attribute for searching. This is because allid
s must be unique within a single XML, so you are guaranteed to find the id.