I'm using a Stringbuilder to build my XQuery statement like so:
Dim xmlColl As New XQueryNavigatorCollection
xmlColl.AddNavigator("[XML File]", "file")
Dim query As New System.Text.StringBuilder
query.Append("for $node in document('file')//person ")
query.Append("where ")
query.Append("fn:contains($node/firstname, 'Pe') and ")
query.Append("fn:contains($node/lastname, 'Euga') ")
query.Append("return ").Append("{$node/FirstName}")
Dim expr As New XQueryExpression(query.ToString())
Dim s As String = expr.Execute(xmlColl).ToXml()
When I try to execute this, I get the Microsoft.XML.XQuery.XQueryException "Expected 'RETURN' where ( encountered." From the examples I've seen online, it looks like the syntax is correct but the exception makes me think otherwise. Can anyone help me out? It's driving me nuts. Any help would be much appreciated.