vb.net写xml文件的简单介绍
vb.net中怎么创建xml文件并写数据
DataSet 和 DataTable都有现成的方法:WriteXml
创新互联是一家专注于成都做网站、网站设计与策划设计,松桃网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:松桃等地区。松桃做网站价格咨询:18982081108
DataTable tb = this.dataGridView1.DataSource as DataTable;
if(tb != null)
{
tb.WriteXml(@"C:\table.xml",true);
return;
}
DataView dv = this.dataGridView1.DataSource as DataView;
if(dv != null)
{
dv.Table.WriteXml(@"C:\table.xml",true);
return;
}
IList list = this.dataGridView1.DataSource as IList;
if(list != null)
{
//to do,如果是IList,就要你自己想办法导出了
//XmlDocument or XmlWriter都可以考虑
}
VB.NET将DataGridView1数据创建XML文件
DataSet
和
DataTable
都有现成的方法:WriteXml
DataTable
tb
=
this.
dataGridView
1.DataSource
as
DataTable;
if(tb
!=
null)
{
tb.WriteXml(@"C:\table.xml",true);
return;
}
DataView
dv
=
this.dataGridView1.DataSource
as
DataView;
if(dv
!=
null)
{
dv.Table.WriteXml(@"C:\table.xml",true);
return;
}
IList
list
=
this.dataGridView1.DataSource
as
IList;
if(list
!=
null)
{
//to
do,如果是IList,就要你自己想办法导出了
//XmlDocument
or
XmlWriter
都可以考虑
}
vb.net XML文件如何写入
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim f As New FileInfo("d:\doc.xml")
If f.Exists = False Then
f.Create()
f.Refresh()
End If
Dim s As String = ""
Dim sw As StreamWriter = f.CreateText()
s = "?xml version=""1.0"" encoding=""GB2312""?"
sw.WriteLine(s)
sw.WriteLine("doc")
sw.WriteLine(" assembly")
sw.WriteLine("userId34/userId")
sw.WriteLine("userName张三/userName")
sw.WriteLine("qxbz1/qxbz")
sw.WriteLine(" /assembly")
sw.WriteLine("/doc")
sw.Flush()
sw.Close()
Process.Start("d:\doc.xml")
End Sub
End Class
网页名称:vb.net写xml文件的简单介绍
标题URL:http://azwzsj.com/article/docgodp.html