Results 1 to 9 of 9

Thread: I can not figure out how to read multiple elements in a xml file

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Re: I can not figure out how to read multiple elements in a xml file

    Thanks for the solution! I'll try it out and post back here with the results.

    I like your solution for my xml file better. I am going to use it. It is a lot better formatted.

    Thanks, I will report back with my results.

  2. #2

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Re: I can not figure out how to read multiple elements in a xml file

    I am having some difficulties getting this code to work.

    This is an image of the program encountering the error.



    Here is the code that reads the xml file.

    Code:
    Public Sub XMLRead()
            Dim ds As New DataSet
            Dim v_name1 As String
            Dim v_date As Date
            Dim v_stage As String = ""
    
            Dim exerciseArray As New ArrayList
            Dim numberOfSetsArray As New ArrayList
            Dim numberOfRepsArray As New ArrayList
            Dim restArray As New ArrayList
            Dim dimensionArray As New ArrayList
            'clear arraylist
            exerciseArray.Clear()
            numberOfSetsArray.Clear()
            numberOfRepsArray.Clear()
            restArray.Clear()
            dimensionArray.Clear()
            ds.ReadXml("sessiondata.xml")
            For Each drSession As DataRow In ds.Tables("Session").Rows
                v_name1 = ds.Tables("Name").ToString()
                v_date = ds.Tables("SessionDate").ToString()
                v_stage = ds.Tables("Stage").ToString()
                For Each drData As DataRow In drSession.GetChildRows("Session_Data")
                    exerciseArray.Add(drData("Exercise").ToString())
                    numberOfSetsArray.Add(drData("NumberOfSets").ToString())
                    numberOfRepsArray.Add(drData("NumberOfReps").ToString())
                    restArray.Add(drData("Rest").ToString())
                    dimensionArray.Add(drData("Dimension").ToString())
                Next
                AddSessionDataForm.sessionDataArrayList.Add(New SessionData(v_name1, v_date, v_stage, _
                             exerciseArray, numberOfSetsArray, numberOfRepsArray, restArray, _
                             dimensionArray))
            Next
        End Sub

    If someone can figure out what I can do to make this sub procedure run, please inform me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width