私は、次のファイルを使用しています:私は以下の結果を得ています私は、XML文書MarkLogic:XML文書から別の名前を取得するXQuery?
for $x at $i in doc("bookstore.xml")/bookstore/book/*
return fn:distinct-values(name($x))
から名前を取得するには、次のクエリを使用しています
<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>
を:
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ループを台無しにしていると思います。誰かがこれを修正して助けてくれる?私はdistinct-values()を使ってみました。運がない。
ありがとうございました。 Xpathは甘くて短いです。できます。どうもありがとう! – happybayes