snippets / Tlaloc / 

All Tlaloc's snippets (1)

  1. Read XML file and Iterate through Rows

    You can call this function on Page load like this: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ReadXMLFile() End Sub

     1 Function ReadXMLFile()        
    2 Dim strBuilder As StringBuilder = New StringBuilder() 'Read XML File
    3 Dim ds As New DataSet()
    4 ds.ReadXml("C:\Website\XMLMadness\App_Data\USA.xml") 'Iterate through the tables in DataSet.
    5 Dim dt As DataTable
    6 dt = ds.Tables(0) 'Iterate through the rows in a table.
    7 Dim n As Integer
    8 For n = 0 To dt.Rows.Count - 1 'Do stuf to your data here.
    9 'strBuilder.Append(dt.Rows(n)(1) & vbCrLf)
    10 strBuilder.Append(dt.Rows(n)(1) & "<br />")
    11 'strBuilder.Append(Chr(34) & dt.Rows(n)(0) & Chr(34) & "<br />")
    12 'Get a different column
    13 'strBuilder.Append(Chr(34) & dt.Rows(n)(1) & Chr(34) & "<br />")
    14 Next
    15 Literal1.Text = strBuilder.ToString
    16 Return strBuilder.ToString()
    17 End Function
    first posted by Tlaloc to visual basic .net read xml iterate through ... saved by 1 person ... 0 comments ... 11 months
showing 10, 25, 50 items per pages

Pages : 1