Trying to filter with XPath - InfoPath Dev
in

InfoPath Dev

Trying to filter with XPath

Last post 08-09-2010 12:11 PM by Potemkine. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-09-2010 11:24 AM

    Trying to filter with XPath

    Hello,

    I am attempting to set up a filter using xPath and a Secondary DataSource (no filter applied as of yet).

    Dim DOM As Xml.XPath.XPathNavigator
    Dim NI As System.Xml.XPath.XPathNodeIterator
    Dim expr As XPathExpression

    DOM = Me.DataSources("My_Secondary_DataSource").CreateNavigator
    expr = DOM.Compile("/dfs:myFields/dfs:dataFields/dfs:My_Secondary_DataSource")
    NI = DOM.Select(expr)

    On the last line of code, I receive the error "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."  

    If I change the last line of code to "NI = DOM.Select(expr, me.NameSpaceManager)", I get an error stating "Error 8 Value of type 'System.Xml.XPath.XPathExpression' cannot be converted to 'String'".

    Any thoughts on how to fix this error?

    Thanks in advance,

    Pinback

     

  • 08-09-2010 11:43 AM In reply to

    Re: Trying to filter with XPath

    Hi, Pinback and if you try:

    NI = DOM.Select("/dfs:myFields/dfs:dataFields/dfs:My_Secondary_DataSource", me.NameSpaceManager)

  • 08-09-2010 11:51 AM In reply to

    Re: Trying to filter with XPath

    Hello Potemkine :)

    When I try:

    NI = DOM.Select("/dfs:myFields/dfs:dataFields/dfs:"My_Secondary_DataSource"[Facility='Mary']", Me.NamespaceManager)

    it reads the code, but the following line:

    MsgBox(NI.Count)

    returns a value of 0 despite the fact there are 4 instance of Mary in "My_Secondary_DataSource".

  • 08-09-2010 12:02 PM In reply to

    Re: Trying to filter with XPath

    Hi, if  Facility is an attribute try this :

    NI = DOM.Select("/dfs:myFields/dfs:dataFields/dfs:"My_Secondary_DataSource"[@Facility='Mary']", Me.NamespaceManager)

  • 08-09-2010 12:07 PM In reply to

    Re: Trying to filter with XPath

    BINGO! :)

    You did it, Potemkine! Thanks so much! :) :)

     

    Pinback

  • 08-09-2010 12:11 PM In reply to

    Re: Trying to filter with XPath

    You're Welcome Pinback :)

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.