Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML NodeLists

Status
Not open for further replies.

ChadJK

IS-IT--Management
Nov 10, 2005
14
0
0
US
I'm trying to turn an XML response into a Word Doc. I'm doing well with formatting the Word doc, but I need help iterating through nodes.

The xml node <_DATA_PROVIDER_COMPARABLE_SALES> repeats 1 or more times. So, I want to go through each instance and dump it into my Word doc report. The test I've been running has FIVE of those nodes and it IS iterating 5 times, but it dumps the same information each time. So, instead of five paragraphs of different information, I have five paragraphs of the same information. Obviously it knows there are five different <_DATA_PROVIDER_COMPARABLE_SALES> nodes, but it doesn't seem to want to move to the next node in my FOR EACH.

Code:
Dim comparableProperties As String = String.Empty
If Not InStr(UCase(xmlForReport.InnerXml()), "NO COMPARABLE PROPERTIES ARE AVAILABLE FOR SUBMITTED ADDRESS") Then
     Dim compPropsString As String = ""
     Dim compPropsList As XmlNodeList = xmlForReport.SelectNodes("//_DATA_PROVIDER_COMPARABLE_SALES")
     For Each prop As XmlNode In compPropsList
          compPropsString = compPropsString & CRLF & CRLF & Chr(9) & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/_PARSED_STREET_ADDRESS/@_HouseNumber").InnerText & " " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/_PARSED_STREET_ADDRESS/@_StreetName").InnerText & " " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/_PARSED_STREET_ADDRESS/@_StreetSuffix").InnerText & ", " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/@_City").InnerText & ", " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/@_PostalCode").InnerText
          compPropsString = compPropsString & CRLF & Chr(9) & "Distance: " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/@_DistanceFromSubjectNumber").InnerText
          compPropsString = compPropsString & CRLF & Chr(9) & "Last Sale: " & FormatCurrency(prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/_PROPERTY_HISTORY/_SALES_HISTORY/@_LastSalesPriceAmount").InnerText, 0, TriState.False, TriState.False, TriState.True) & " on " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/_PROPERTY_HISTORY/_SALES_HISTORY/@_LastSalesDate").InnerText
          compPropsString = compPropsString & CRLF & Chr(9) & "Living Area: " & prop.SelectSingleNode("//_DATA_PROVIDER_COMPARABLE_SALES/PROPERTY/_PROPERTY_CHARACTERISTICS/_IMPROVEMENTS/_ROOM_COUNT/@_TotalLivingAreaSquareFeetNumber").InnerText & " sq. ft."
     Next
     Dim compPropsPara As Word.Paragraph
     compPropsPara = avmReportDoc.Content.Paragraphs.Add
     compPropsPara.Range.Text = compPropsString
     compPropsPara.Range.Font.Size = 10
     compPropsPara.Range.Font.Name = "Verdana"
     compPropsPara.Range.Font.Color = Word.WdColor.wdColorBlack
     compPropsPara.Range.Font.Bold = True
     compPropsPara.Range.Font.Italic = False
     compPropsPara.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
     compPropsPara.Range.InsertParagraphAfter()
     compPropsPara = Nothing
     compPropsList = Nothing
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top