0

我在 Microsoft.Xml.XQuery 中较新,当我尝试使用 sum 之类的数学表达式运行 xquery 时,出现错误:无法将添加应用于非整数数据。

XML:

<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>

查询:

for $item in document("xqt")/bookstore/book[price < '30']
return $item/year/text()  +  $item/year/text() 

C#:

  XmlDocument doc1 = new XmlDocument();
        doc1.LoadXml(rteXml.Text);
        XQueryNavigatorCollection navCol = new XQueryNavigatorCollection();
        navCol.AddNavigator(doc1.CreateNavigator(), "xqt");

        XQueryExpression expr = new XQueryExpression(rteXQuery.Text.Trim().Replace("\\n", " "));

        XQueryNavigator nav = expr.Execute(navCol);

        rteOutput.Text = nav.ToXml();

有任何想法吗?

4

1 回答 1

0
for $item in document("xqt")/bookstore/book[price < '30']
return sum($item/year/text(), $item/price/text()) 
于 2013-05-03T07:10:39.020 回答