AS3 - 最深的XML元素 [英] AS3 - Deepest XML Elements
问题描述
我建立一个XML编辑器,我有一个小麻烦解析将传入的XML文件。
I've building an XML editor and am having a little trouble parsing XML files that are passed in.
目前,我只能分析一定深度的XML元素,我想知道你如何能得到最深的XML元素,因为此刻我有一系列的针对每个遍历xmlElem.children该循环()但这只是让我分析有一定的深度,所以这是相当有限的。
At the moment I can only parse a certain depth of XML elements, and I was wondering how you could get the deepest XML element, because at the moment I have a series of for each loops that loop through xmlElem.children() but this only allows me to parse to a certain depth, so it's rather limited.
任何帮助AP preciated!
Any help appreciated!
干杯, 哈利。
推荐答案
听起来像是递归的 http://en.wikipedia.org/wiki/Recursion_%28computer_science%29
此功能将遍历整个XML结构,而不管其大小/深度。
This function will traverse the entire XML structure, regardless of its size/depth.
function parseChildren(parent:XML):void {
for each(child:XML in parent.children()) {
//do whaterver...
if(child.children().length() > 0) {
parseChildren(child);
{
}
}
这篇关于AS3 - 最深的XML元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!