数据在ASP.Net中导出为XML格式 [英] Data Export into XML Format in ASP.Net
本文介绍了数据在ASP.Net中导出为XML格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我将ASP.Net/SQL中的数据成功导出到xml。
下面是代码
Dear,
I export Data from ASP.Net/SQL to xml successfully.
Below is the code
Dim ds As New DataSet()
Try
Dim con As New SqlConnection("server=BAK;initial catalog=Test;uid=sa;pwd=sa")
con.Open()
Dim da As New SqlDataAdapter("select Emp_No,Emp_Name,Emp_GSM1 from Employee", con)
da.Fill(ds, "Employee")
Catch
'Label1.Text = "Error while connecting to a database"
End Try
Dim doc As New XmlDataDocument(ds)
Xml1.Document = doc
doc.Save("D:\Employee.xml")
但是我面临的问题是,当Emp_GSM1为空值时,它不会显示在XML文件中。
示例:。
But what i'm facing the problem, when Emp_GSM1 is null value then its not showing in XML file.
Example:.
<?xml version="1.0"?>
-<NewDataSet>
<Employee>
<Emp_No>1</Emp_No>
<Emp_Name>A</Emp_Name>
<Emp_GSM1>122</Emp_GSM1>
</Employee>
<Employee>
<Emp_No>2</Emp_No>
<Emp_Name>B</Emp_Name> ''here not exporting becoz Emp_GSM1
</Employee>
</NewDataSet>
如何使用偶数值导出xml。
谢谢
Basit。
How to export xml with even null value.
Thanks
Basit.
推荐答案
你可以在这里找到答案:
http://stackoverflow.com/questions/4903655/dataset -getxml-doesnt-return-xml-for-null-or-blank-columns [ ^ ]
和
http:/ /stackoverflow.com/questions/2912723/dataset-writexml-does-not-write-an-empty-tag-if-the-field-was-empty-c-sharp/14857387#14857387 [ ^ ]
You can find the answer here:
http://stackoverflow.com/questions/4903655/dataset-getxml-doesnt-return-xml-for-null-or-blank-columns[^]
and
http://stackoverflow.com/questions/2912723/dataset-writexml-does-not-write-an-empty-tag-if-the-field-was-empty-c-sharp/14857387#14857387[^]
这篇关于数据在ASP.Net中导出为XML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文