|  | 网站首页 | .Net研究 | 
您现在的位置: 程序员之路 >> .Net研究 >> 语言技术区 >> 新手技术 >> 文章正文
赞助商链接
频 道 导 航
.Net研究频道栏目导航
相 关 文 章
XML数据与数据集之间的相互转化           
XML数据与数据集之间的相互转化
作者:richardt… 文章来源:不详 更新时间:2007-5-10 11:05:10

以下代码段实现从DataTable到XML数据的转化过程:

 1 Public Function ConvertDataTableToXML(ByVal strTableName As StringByVal dt As DataTable) As String
 2
 3        Dim xmldoc As New XmlDocument()
 4
 5        Dim strXML As String = String.Empty
 6        Dim sb As New StringBuilder
 7        Dim sw As New IO.StringWriter(sb)
 8        dt.WriteXml(sw)
 9        sw.Close()
10        xmldoc.InnerXml = sb.ToString
11
12        strXML = "<" & strTableName & ">"
13        If Not xmldoc.FirstChild Is Nothing AndAlso _
14        Not xmldoc.FirstChild.FirstChild Is Nothing Then
15            strXML = strXML & xmldoc.FirstChild.FirstChild.InnerXml
16        End If
17        strXML = strXML & "</" & strTableName & ">"
18
19        strXML = strXML.Replace("&lt;""<

[1] [2] [3] 下一页

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • .Net研究栏目导航
    网站频道导航