DataSet.GetXml没有返回null结果 [英] DataSet.GetXml not returning null results

查看:390
本文介绍了DataSet.GetXml没有返回null结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我转换DatSet与DataSet.GetXml一个XML,任何空值将被忽略,所以,在这里我想到这一点:

whenever I convert a DatSet into an XML with DataSet.GetXml, any null value is ignored, so, where i expect this:

<value1>a</value1>
<value2></value2>
<value3>c</value3>

我得到这个代替:

I get this instead:

<value1>a</value1>
<value3>c</value3>

任何快速和肮脏的方式来处理呢?
谢谢

Any quick and dirty way to handle this? Thanks

编辑:
我认为一个解决方案将使用中WriteXML。谁能给我提供使用它的样本,而无需编写一个文件,但得到一样的getXML做一个字符串?谢谢

I think a solution would be using WriteXml. Could anyone provide me with a sample of using it WITHOUT writing to a file but getting a string just like GetXml does? Thanks

推荐答案

的问题是在这里列出的Microsoft知识库文章中:

The problem is listed here in the Microsoft KB article:

http://support.microsoft.com/default。 ASPX SCID = KB; EN-US; Q317961

问题是,你没有连接到您的数据集的架构,指定该元素应该被写出来。

The problem is that you have no schema attached to your dataset that specifies that that element should be written out.

我不认为使用会中WriteXML解决这个问题,作为文档状态,调用此方法等同于调用带有XmlWriteMode设置为IgnoreSchema中WriteXML。但你可以自由地尝试 - 这里是相当于code:

I don't believe that using WriteXml will solve the problem, as the documentation states, "Calling this method is identical to calling WriteXml with XmlWriteMode set to IgnoreSchema." but you are free to try - here is the equivalent code:

StringWriter sw = new StringWriter();
ds.WriteXml(sw);
string outputXml = sw.ToString();

这篇关于DataSet.GetXml没有返回null结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆