1 Replies - 10050 Views - Last Post: 10 February 2009 - 09:52 PM Rate Topic: -----

#1 GBQuest   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 26-January 09

Writing to an existing XML file

Post icon  Posted 10 February 2009 - 05:52 PM

i have started a program that reads the names, number and picture location from an xml file and populates text boxes. I now want to be able to update the text boxes and rewrite the xml file and save it to the same location.

Imports System.Xml

Dim H1 As New XmlDocument()

Dim xlist As XmlNodeList = H1.SelectNodes("/item//name")

		Dim values As String = ""
		Dim Name() As String = Nothing

		For Each node As XmlNode In xlist
			values = node.InnerXml 
		Name = values.Split(",")

		Dim s As String
		For Each s In Name
		Next s
			txt0.Text = Name(0)
			txt1.Text = Name(1)
			txt2.Text = Name(2)
			txt3.Text = Name(3)
			txt4.Text = Name(4)
			txt5.Text = Name(5)
			txt6.Text = Name(6)
			txt7.Text = Name(7)

		End Try

now after i update any of the names i would like to hit an update button and replace the old name with a new one.

any assistance would be so great.

This post has been edited by GBQuest: 10 February 2009 - 06:10 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Writing to an existing XML file

#2 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 783
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: Writing to an existing XML file

Posted 10 February 2009 - 09:52 PM

You can try using the XmlTextWriter class to write to an XML file:


If you will write to an existing file, it will replace the file contents with the contents you specified, so make sure you update the records properly or you may lose the stored information.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1