我想获取当前xml节点的所有祖先。例如:
<nav url="navurl">
<l lo="def">XML Parsing</l>
<m url="M Level 1">
<l lo="en_GB">Location</l>
<m url="M Level 2">
<l lo="en_GB">Other Countries</l>
<m url="M Level 3">
<l lo="en_GB">Europe</l>
<u url="U Level 4">
<l lo="en_GB">Austria</l>
</u>
<m url="M Level 4">
<l lo="en_GB">Slovakia</l>
<u url="U Level 5">
<l lo="def">Applications</l>
</u>
</m>
<u url="U Level 4">
<l lo="en_GB">NewUrl</l>
</u>
</m>
</m>
</m>
</nav>
这是预期的输出:
O/p:
1: m:->m:->m:->u:->l ( Till Australia)
2: m:->m:->m:->m:->l (Till Slowakia)
3: m:->m:->m:->m:->u (Till Applications)
4: m:->m:->m:->u (Till New URL)
请注意,'m','l'和'u'是唯一的标签名称,这些标签可以重复使用'N'次。我怎样才能得到这个输出?