我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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文件的简单介绍
路径分享:http://mswzjz.cn/article/docgodp.html

其他资讯