SelectNodes Xpath Contains - Getting XSLT Unknown Function error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tschulken@gmail.com

    SelectNodes Xpath Contains - Getting XSLT Unknown Function error

    I am trying to get certain nodes within an xml doc that contain certain
    text (similar to a SQL LIKE). In doing so I am using the XPATH Contains
    function and have not been successful. When I run I get the following
    error:
    System.Xml.XPat h.XPathExceptio n: XsltContext is needed for this query
    because of an unknown function.

    I can successfully get simple xpath queries to work, just none using
    the Contains function. Any help would be appreciated.

    ---------------------------------------------------------
    Dim dom As New XmlDocument
    Dim nodeList As XmlNodeList
    Dim nsManager As New XmlNamespaceMan ager(dom.NameTa ble)

    nsManager.AddNa mespace("xsi",
    "http://www.w3.org/2001/XMLSchema-instance")

    dom.Load(txtFil e.Text)

    Dim query As String = "//TypeName[Contains(., '_LU_')]"
    nodeList = dom.SelectNodes (query, nsManager)

    Tim

  • Martin Honnen

    #2
    Re: SelectNodes Xpath Contains - Getting XSLT Unknown Function error



    tschulken@gmail .com wrote:

    [color=blue]
    > Dim query As String = "//TypeName[Contains(., '_LU_')]"[/color]

    You are VB impaired where case does not matter but for XPath and XSLT
    function names it does matter so try the function 'contains':
    "//TypeName[contains(., '_LU_')]"

    --

    Martin Honnen --- MVP XML

    Comment

    • tschulken

      #3
      Re: SelectNodes Xpath Contains - Getting XSLT Unknown Function error

      Martin, thanks for easily spotting that!!

      Comment

      Working...