可能重复:
XQuery 返回错误..?
以下是 XML 文件 -
<Continents>
<Continent name="Asia">
<Country name="Japan">
<City name="Tokyo"><Desc>Tokoyo is a most populated City</Desc></City>
<City name="Horishima"><Desc>What to say.. Faced the destruction due to Atom Bomb</Desc></City>
</Country>
<Country name="India">
<City name="New Delhi"><Desc>Capital of India</Desc></City>
<City name="Mumbai"><Desc>Financial Capital of India</Desc></City>
<City name="Lucknow"><Desc>City of Nawabs</Desc></City>
</Country>
</Continent>
</Continents>
我想列出国家的城市="India"
我的 XQuery FLWOR 代码是 -
for $x in doc("Continent")/Continents/Continent
where $x/Country/@name='India'
return $x/Country/City/@name
我希望输出为 -
name="New Delhi" name="Mumbai" name="Lucknow"
但得到输出 -
name="Tokyo" name="Horishima" name="New Delhi" name="Mumbai" name="Lucknow"
任何人都可以帮助我获得正确的输出吗?另外如何将它放在单独的行上?