i need to write to an xml file, from an xml file i have created


I am using vb.net to read an xml file with basic user information.  I want to be able to write back to a new xml file, and maybe do some logic like bind firstName and surName elements together.

Any clues of writing, using the elements already obtained from the read function?


Public Sub MigrateFromOldToNew()
        Dim xmlFilePath As String = HttpContext.Current.Server.MapPath("Students.xml")
            Using reader As XmlReader = XmlReader.Create(xmlFilePath)
                While (reader.Read)
                    If (reader.NodeType = XmlNodeType.Element) Then
                        If (reader.Name = "StudentId") Then
                            studentId = reader.ReadInnerXml
                        End If
                        If (reader.Name = "StudentName") Then
                            studentName = reader.ReadInnerXml
                        End If
                        If (reader.Name = "StudentSurname") Then
                            studentSurname = reader.ReadInnerXml
                        End If
                    End If
                End While
            End Using
        Catch ex As Exception
        End Try
    End Sub

Open in new window

Who is Participating?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.