使xml向下钻取 [英] make the xml drill down

查看:104
本文介绍了使xml向下钻取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含不同级别的xml文档:

We have an xml doc that contains different levels:

<Root>
	<folder name="aaa">
		<folder name="abb">
			<file name="ccc.pdf" url="c:\test\ccc.pdf"/>
			<file name="ddd.pdf" url="c:\test\ddd.pdf"/>
			<file name="eee.pdf" url="c:\test\eee.pdf"/>
			<file name="fff.pdf" url="c:\test\fff.pdf"/>
		</folder>
		<folder name="acc">
			<file name="ggg.pdf" url="c:\test\ggg.pdf"/>
			<file name="hhh.pdf" url="c:\test\hhh.pdf"/>
		</folder>
	</folder>
	<folder name="bbb">
		<folder name="bba">
			<file name="iii.pdf" url="c:\test\iii.pdf"/>
		</folder>
		<folder name="bbc" />
	</folder>
	<folder name="ccc">
			<file name="iii.pdf" url="c:\test\iii.pdf"/>
			<file name="jjj.pdf" url="c:\test\jjj.pdf"/>
			<file name="kkk.pdf" url="c:\test\kkk.pdf"/>
			<file name="lll.pdf" url="c:\test\lll.pdf"/>
	</folder>
</Root>



我的问题是如何使用xsl来制作xml向下钻取,例如展开折叠(切换)文件夹名称。并使文件可链接(通过属性url)


My question is how to using xsl to make the xml drill down like expand collapse(toggle) the folder name. and also make the file linkable (by the attribute url)

推荐答案

你在显示的是没有xml。

xml没有使用xsl向下钻取。您可以使用xsl转换以不同方式查看数据,但我认为这不是您想要的。



我认为您想要做的是读取将xml转换为dom,并使用XPath查询查找不同的数据片段。向谷歌询问'XPath'。



[mod 1]

好​​的,你改变了问题,以便呈现的数据现在是xml格式。你的问题仍然模糊不清,但我认为你想要的答案仍然是使用XPath,无论你想做什么。
What you are displaying there is not xml.
The xml does not "drill down" using xsl. You can use xsl transforms to look at the data in different ways but I don't think that is what you want.

I think what you want to do is read the xml into a dom, and use XPath queries to find different pieces of the data. Ask Google about 'XPath'.

[mod 1]
Okay, you changed the question so that the data presented is now in xml format. Your question is still vague, but I think the answer you want is still to use XPath for whatever it is you are trying to do.


这篇关于使xml向下钻取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆