locked
Problem searching node in a XML Data Source RRS feed

  • Question

  • Hi Guys,

    I'm having problem searching a node in my XML Data Source(Secondary).

    in this line below it always return Nothing, even if the "htsInput" has value and available in the node

     hts = htsDS.SelectSingleNode( _
                "/ns1:HTS/ns1:HTS_Files[@ITEM = '" & htsInput & "']", NamespaceManager)

    Public Sub PopulateHTS() Dim ddlNav As XPathNavigator Dim htsDS As XPathNavigator Dim hts As XPathNavigator Dim htsDisplay As String = String.Empty Dim htsInput As String = String.Empty Try ddlNav = MainDataSource.CreateNavigator htsInput = ddlNav.SelectSingleNode("/my:myFields/my:FormInformation/my:RMAPreparation/my:GroupItemsRMAPrep/my:StyleNo", NamespaceManager).Value ' Retrieve a reference to the XML Data Source

    htsDS = DataSources("HTS_DS3").CreateNavigator() ' Search for the Part/StyleNo in the HTS Master list hts = htsDS.SelectSingleNode( _ "/ns1:HTS/ns1:HTS_Files[@ITEM = '" & htsInput & "']", NamespaceManager) ' Check whether the search returned a result and ' if it did, retrieve the HTS of the Part/StyleNo If hts IsNot Nothing Then htsDisplay = hts.SelectSingleNode("@CATEGORY", NamespaceManager).Value End If ' Set dropdown displayname ddlNav.SelectSingleNode("//my:HTS", NamespaceManager).SetValue(htsDisplay) Catch ex As Exception errorStr = ex.ToString Finally ddlNav = Nothing htsDS = Nothing hts = Nothing htsDisplay = Nothing End Try End Sub

    Thanks for the help.


    ®©™½¼


    • Edited by jwill92 Thursday, May 24, 2012 3:11 PM
    Thursday, May 24, 2012 3:10 PM

Answers

  • the best way to view you query is:

    Do a temporary rule in InfoPath Designer. Add a new Action. In Action select Set a field`s value.

    For Value field go in formula window. Set there your node with Filter Data...

    After that check "Edit XPath(advanced)" check box. Obtain xpath string. After that you can use/ modify this string (Xpath) in your code dynamically change value 


    Friday, May 25, 2012 9:03 AM