Code :
Form1.vb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xmlfilepath As String = Application.StartupPath & "\info.xml"
Dim ds As New DataSet("info")
Dim dt As New DataTable("info")
Dim dr As DataRow
dt.Columns.Add("fname", GetType(String))
dt.Columns.Add("lname", GetType(String))
dt.Columns.Add("ph", GetType(Integer))
ds.Tables.Add(dt)
dr = ds.Tables("info").NewRow
dr("fname") = "poonam"
dr("lname") = "v"
dr("ph") = "878769"
dt.Rows.Add(dr)
ds.WriteXml(xmlfilepath, XmlWriteMode.WriteSchema)
Me.DataGridView1.DataSource = ds.Tables("info")
End Sub
Button Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As New System.IO.StringWriter
Dim d As New DataSet
d.ReadXml("C:\poonam\eg of writexml\eg of writexml\XMLFile1.xml")
d.WriteXmlSchema(s)
TextBox1.Text = s.ToString
End Sub
End Class
Xml File:
xml version="1.0" encoding="utf-8" ?>
<employee>
<employee eid="1" ename="sdd"/>
employee>
No comments:
Post a Comment