EDN Admin
Well-known member
Have anyone a example to use the order by clause?
My Code:
use: Microsoft.Xml.XQuery
XML document:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<test>1</test>
<test>4</test>
<test>3</test>
<test>5</test>
<test>6</test>
<test>2</test>
<test>7</test>
</root>
Microsoft.Xml.XQuery.XQueryNavigatorCollection qnav = new Microsoft.Xml.XQuery.XQueryNavigatorCollection();
qnav.AddNavigator(@"H:ManfredProjekteTestXQueryTestXQueryTestXQueryTestXMLFile1.xml", "foo");
string query =
@"for $x in document(""foo"")//test
order by $x:number[1] descending
return $x";
try
{
Microsoft.Xml.XQuery.XQueryExpression xq = new Microsoft.Xml.XQuery.XQueryExpression(query);
Microsoft.Xml.XQuery.XQueryNavigator res = xq.Execute(qnav);
System.Console.Write(res.ToXml());
}
catch (Exception e)
{
string stemp = e.StackTrace;
}
Exception is all the time the same: "Expected RETURN where order encountered." - what agreat Exception message!!!
Thanks for any sugestions
There is NO Forum classification for such a post regarding XML or XQuery!
View the full article
My Code:
use: Microsoft.Xml.XQuery
XML document:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<test>1</test>
<test>4</test>
<test>3</test>
<test>5</test>
<test>6</test>
<test>2</test>
<test>7</test>
</root>
Microsoft.Xml.XQuery.XQueryNavigatorCollection qnav = new Microsoft.Xml.XQuery.XQueryNavigatorCollection();
qnav.AddNavigator(@"H:ManfredProjekteTestXQueryTestXQueryTestXQueryTestXMLFile1.xml", "foo");
string query =
@"for $x in document(""foo"")//test
order by $x:number[1] descending
return $x";
try
{
Microsoft.Xml.XQuery.XQueryExpression xq = new Microsoft.Xml.XQuery.XQueryExpression(query);
Microsoft.Xml.XQuery.XQueryNavigator res = xq.Execute(qnav);
System.Console.Write(res.ToXml());
}
catch (Exception e)
{
string stemp = e.StackTrace;
}
Exception is all the time the same: "Expected RETURN where order encountered." - what agreat Exception message!!!
Thanks for any sugestions
There is NO Forum classification for such a post regarding XML or XQuery!
View the full article