Problems with XML filtering - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Problems with XML filtering

Last post 08-31-2017 11:32 AM by Hilary Stoupa. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-29-2017 07:38 AM

    Problems with XML filtering

    This should be real simple, but I have spent numerous hours trying to get it to work and with very little luck. I have a secondary data connection to a SharePoint List that I am trying to pull a record based on the ID (simple huh?) I have tried both of these versions of the select and cant get it to do a match for me. I have verified the record does exist with the ID = 14 and I have tried with and without the single quotes on 14. Each time the Pointer returns null. Any Ideas? Thanks so much!! XPathNavigator myPricelist = DataSources["Pricelist"].CreateNavigator(); XPathNavigator Pointer = myPricelist.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[@ID='14']", NamespaceManager); AND XPathNavigator myPricelist = DataSources["Pricelist"].CreateNavigator(); XPathNodeIterator Prices = myPricelist.Select("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW", NamespaceManager); XPathNavigator Pointer = Prices.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[@ID='14']", NamespaceManager);
    Filed under:
  • 08-29-2017 07:49 AM In reply to

    Re: Problems with XML filtering

    A little more info. I have also tried all of the variations with "@d:ID=14 Still cant get any of them to locate the record.
  • 08-29-2017 08:08 AM In reply to

    Re: Problems with XML filtering

    Your XPath is incorrect, I think. In the form, in design mode, in the Fields task pane, select the PriceList data source. Right click the ID node and select Copy XPath. I'm thinking it is going to be "d:ID", not "@ID".
    Hilary Stoupa

  • 08-30-2017 04:49 AM In reply to

    Re: Problems with XML filtering

    Thanks Hilary! I have twisted and turned this every which way I can and have been unable to get a return value. This is what I am down to: XPathNavigator myPricelist = DataSources["Pricelist"].CreateNavigator(); XPathNodeIterator Prices = myPricelist.Select("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW", NamespaceManager); XPathNavigator myItem = Prices.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/Title[@d:ID=14]", NamespaceManager); myItem always returns null. I have just run with the default NamespaceManager, I am handling a main data source also, do I need to define a separate NamespaceManager? I have searched the web over and over, not able to find a good example of how to deal with SharePoint files. Any alternative format or insight you can give me would be appreciated. You are the Greatest!! Thanks So Much!!
  • 08-30-2017 08:16 AM In reply to

    Re: Problems with XML filtering

     I think your XPath is incorrect for the ID node. It is not "@:ID". It is not "@d:ID". I think it is "d:ID".

    XPathNavigator myPricelist = DataSources["Pricelist"].CreateNavigator();
    XPathNavigator Pointer = myPricelist.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:ID=14]", NamespaceManager)

    You do not need a separate namespace manager, you just need the correct XPath. :)

    Hilary Stoupa

  • 08-31-2017 08:13 AM In reply to

    Re: Problems with XML filtering

    You were exactly correct. I think I am getting to the heart of my problem, I hope I can communicate it well enough. Obviously, there is something (probably lots) I don't understand about processing xml. XPathNavigator myKits = DataSources["Kits"].CreateNavigator(); XPathNodeIterator KitItem = myKits.Select("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW", NamespaceManager); I DECIDED TO NAVIGATE THROUGH EACH RECORD the only record I can seem to return is the first record, which has an ID OF "6" (THIS IS COMING FROM MY IMMEDIATE WINDOW) ? KitItem.Count // I have 23 records in my list 23 ? KitItem.CurrentPosition 3 ? KitItem.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID", NamespaceManager).Value; "6" ? KitItem.CurrentPosition 4 ? KitItem.Current.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID", NamespaceManager).Value; "6"
  • 08-31-2017 11:28 AM In reply to

    Re: Problems with XML filtering

     Try using a foreach if you need to iterate through the entire set of records  - I am having a hard time making sense of your code other than the first two lines (try using IE when posting to the forum - it is an older version and does best with IE).

    foreach(XPathNavigator kit in KitItem)

    { //do stuff here} 

    Hilary Stoupa

  • 08-31-2017 11:32 AM In reply to

    Re: Problems with XML filtering

     Also - you may find this MSDN link helpful: https://msdn.microsoft.com/en-us/library/office/aa945227.aspx

    Hilary Stoupa

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