【发布时间】:2016-04-11 23:00:01
【问题描述】:
我正在使用以下文件:
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
我正在使用以下查询从 XML 文档中获取名称
for $x at $i in doc("bookstore.xml")/bookstore/book/*
return fn:distinct-values(name($x))
我得到以下结果:
title
author
year
price
title
author
year
price
title
author
author
author
author
author
year
price
title
author
year
price
相反,我只想要一个不同的,如下所示。
title
author
year
price
我相信我搞砸了 for 循环。有人可以帮我解决这个问题吗?我尝试使用不同的值()。没有运气。
【问题讨论】: