|
Answer» As all of us know xml is platform independent language so we can use xml in ANOTHER platforms very easily. In vb.net we use XmlTextWriter class to CREATE new xml file. And code is given below:-
Imports System.Xml Public Class Form1 Private Sub Btnxmlcreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnxmlcreate.Click Dim writer As New XmlTextWriter("xmlfilename.xml", System.Text.Encoding.UTF8) writer.WriteStartDocument(True) writer.Formatting = Formatting.Indented writer.Indentation = 2 writer.WriteStartElement("Table") createxmlNode(1, "interviewqsn.com") createxmlNode(2, "getproductprice.com") writer.WriteEndElement() writer.WriteEndDocument() writer.Close() END Sub Private Sub createxmlNode(ByVal pID As String, ByVal pName As String, ByVal pPrice As String, ByVal writer As XmlTextWriter) writer.WriteStartElement("Product") writer.WriteStartElement("Product_id") writer.WriteString(pID) writer.WriteEndElement() writer.WriteStartElement("Product_name") writer.WriteString(pName) writer.WriteEndElement() writer.WriteEndElement() End Sub End Class
|