Hi..
I am fairly new to Vb.Net. Can anyone please let me know how to write/append a XML document using Vb.net
I have this xml
<root>
<online>abc</online>
<online>dfshgh</online>
</root>
Now i want to append the <online> tag of the xml file with more such records
how can i do that ..if any one give an example code is more prefered as the other example i have seen is not clear

XML writing through VB.Net
IronYuppie
Any one out there to help me that how can i write a XML file online....using VB.Net
I need it badly and haven't found any solution to it...
I have a XML file in remote location accessable through a web link like http://xyz.com/myfile.xml and i just want to update that.....
Steve Teixeira
thanks for the info. Sorry i read the thread little late...
Well If i Use the Dataset to write the xml even than i have to write the whole xml file from beginning...
Well if yes than why the hell microsoft make the xml namespace...and for what it is good to use....
paulconstantine
Well my problem seems to get solved....Thanks for your help...
Writing XML file for me is not working when I try to write it using Internet address... like http://xyz.com/myfile.xml because i passes the file name with http: when i pass it without it i am able to write the xml file and all example works fine....
So moral of story it that for writing online xml file you doesn't need to pass the protocol in your file address...:)
dshaykewich
Option Explicit
Option Strict
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim doc As New XmlDocument()
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _
"<title>Pride And Prejudice</title>" & _
"</book>")
Dim root As XmlNode = doc.DocumentElement
'Create a new node.
Dim elem As XmlElement = doc.CreateElement("price")
elem.InnerText = "19.95"
'Add the node to the document.
root.PrependChild(elem)
Console.WriteLine("Display the modified XML...")
doc.Save(Console.Out)
End Sub 'Main
End Class 'Sample
Randine
What you have is more of an INI file than an XML document... Yes, you're using XML tag format, but the document is not well defined.
If all you need is a file that simple (a single list of element values) you should just use plain text and not even bother with the XML style tagging. Or, if some other application needs the tags, just open the file as a text stream, add your values to it, and write the whole thing over. Your <root> and </root> tags are always first and last and the "elements" in between are all the same; only the values differ and they have no sub elements.
If you want to use the Microsoft XML engine, you'll need to do a lot more XML coding with your data file; which looks like overkill for what you're trying to accomplish.