Problem with XPath 'substring' function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pnunbe
    New Member
    • May 2010
    • 2

    Problem with XPath 'substring' function

    Hi,

    I have a problem with the 'substring' function of XPath in VB.NET (VS 2005).

    My code looks like this:
    Code:
      dim Dom As new XmlDocument
        Dim mgr As New XmlNamespaceManager(Dom.NameTable)
       'mgr.AddNamespace("fn", "http://www.w3.org/2005/xpath-functions/#substring")
       mgr.AddNamespace("fn", "http://www.w3.org/2005/xpath-functions")
        Dom.Load(fileXml)
       Dim nodeList As XmlNodeList
       Dim root As XmlNode = Dom.DocumentElement
       nodeList = root.SelectNodes("//*[fn:substring(@MittDest,1,1)='a']", mgr)
    I get the following message (translated from italian)

    "XsltContex t is necessary for the query due to an unknown function."

    Neither of the two AddNameSpace statements works.

    Any suggestions?

    Thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    does it work without the "fn" namespace? (I only used XPath functions in XSLT, but there I didn’t need a namespace)

    Comment

    • pnunbe
      New Member
      • May 2010
      • 2

      #3
      Originally posted by Dormilich
      does it work without the "fn" namespace? (I only used XPath functions in XSLT, but there I didn’t need a namespace)
      Yes, it does work!

      Thanks a lot

      Comment

      Working...