2013-05-02 52 views
0

我在Microsoft.Xml.XQuery中更新,当我试图运行带有数学表达式的xquery时,如sum我有错误:无法应用添加到非整数数据。Microsoft.Xml.XQuery数学表达式错误

XML:

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

的XQuery:

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(); 

任何想法?

+0

从来没有听说过这个API。它是SQL Server的一部分吗? – 2013-05-02 13:18:41

+0

请参阅这些http://xqueryservices.com或www.pietsieg.com/articles\xquery\beginner\在ASP.NET中使用XQuery - OLD MS XQuery演示\在ASP.NET.htm中使用XQuery – 2013-05-02 13:34:16

+0

这些链接都不适用于我。第二个甚至不是一个链接。 – 2013-05-02 17:02:39

回答

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