There are multiple occurances of the PLUS_BORROWER data. For each occurence of PLUS_BORROWER, I want to save the CREDIT_SCORE and DAYTIME_PHONE_NBR when the Type= And SOCIAL_SECURITY_NBR are certain values.

Then I want to execute a loop and extract the Credit_Score and Daytime_Phone_Nbrs.

<PLUS_BORROWER Type="Primary">
        <SOCIAL_SECURITY_NBR>123459999</SOCIAL_SECURITY_NBR>
        <CREDIT_SCORE ModelName="Emperica">793</CREDIT_SCORE> 
        <DAYTIME_PHONE_NBR>4077889999</DAYTIME_PHONE_NBR>
        <DAYTIME_PHONE_EXT>101</DAYTIME_PHONE_EXT>
</PLUS_BORROWER>

I have the following code that will pull off the first PLUS_BORROWER if the Type='Primary', but I am having trouble expanding it.

oExtraData.Load(myXMLFile)     
        'only select nod with type attribute equal primary
        Dim oNode As Xml.XmlNode = oExtraData.SelectSingleNode("//PLUS_BORROWER[@Type='Primary']")
        'get credit score node
        Dim scoreNode As Xml.XmlNode = oNode.SelectSingleNode("CREDIT_SCORE")
        MsgBox("I have the Primary")
        MsgBox("Credit score is " & scoreNode.InnerText)

Here you have

' My test file!
Dim myXMLFile As String = "D:\test.xml"

Dim oStream As FileStream
Dim XReader As Xml.XmlTextReader
Dim XDoc As XPath.XPathDocument
Dim XNav As XPath.XPathNavigator
Dim XIter As XPath.XPathNodeIterator
Dim TempStr As String

oStream = New FileStream(myXMLFile, FileMode.Open)
XReader = New Xml.XmlTextReader(oStream)
XDoc = New XPath.XPathDocument(XReader)
XNav = XDoc.CreateNavigator()
XNav.MoveToRoot()
XIter = XNav.Select("descendant::PLUS_BORROWER[@Type='Primary']")

While XIter.MoveNext
  ' Get a value (CREDIT_SCORE)
  TempStr = XIter.Current.SelectSingleNode("descendant::CREDIT_SCORE").Value
  MsgBox("I have the Primary")
  MsgBox("Credit score is " & TempStr)
End While

DAYTIME_PHONE_NBR is "extracted" in the same way. My test file was:

<BORROWERS>
<PLUS_BORROWER Type="Primary">        
        <SOCIAL_SECURITY_NBR>123459999</SOCIAL_SECURITY_NBR>
        <CREDIT_SCORE ModelName="Emperica">793</CREDIT_SCORE> 
        <DAYTIME_PHONE_NBR>4077889999</DAYTIME_PHONE_NBR>
        <DAYTIME_PHONE_EXT>101</DAYTIME_PHONE_EXT>
</PLUS_BORROWER>
<PLUS_BORROWER Type="NonPrimary">
        <SOCIAL_SECURITY_NBR>123459999</SOCIAL_SECURITY_NBR>
        <CREDIT_SCORE ModelName="Emperica">800</CREDIT_SCORE> 
        <DAYTIME_PHONE_NBR>4077889999</DAYTIME_PHONE_NBR>
        <DAYTIME_PHONE_EXT>101</DAYTIME_PHONE_EXT>
</PLUS_BORROWER>
<PLUS_BORROWER Type="Primary">
        <SOCIAL_SECURITY_NBR>290165</SOCIAL_SECURITY_NBR>
        <CREDIT_SCORE ModelName="Emperica">666</CREDIT_SCORE> 
        <DAYTIME_PHONE_NBR>555666777</DAYTIME_PHONE_NBR>
        <DAYTIME_PHONE_EXT>101</DAYTIME_PHONE_EXT>
</PLUS_BORROWER>
</BORROWERS>

so the first and the third PLUS_BORROWER's CREDIT_SCORE's are displayed.

This article has been dead for over six months. Start a new discussion instead.