DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: XQuery String Searches

  1. #1
    Join Date
    Jun 2005

    Thumbs down XQuery String Searches

    I am trying to do a web page search against a large XML file with the following format:


    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.
    Attached Images Attached Images
    Last edited by gyochum; 06-28-2005 at 09:24 AM.

  2. #2
    Join Date
    Jun 2005

    Found the answer

    I've found the answer and it's a little embarrassing - take off the "fn:" and you're good to go

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center