DataSet.GetXml不返回null结果 [英] DataSet.GetXml not returning null results
问题描述
< value1> a< / value1>
< value2>< / value2>
< value3> c< / value3>
我取而代之:
< value1> a< / value1>
< value3> c< / value3>
任何快速而肮脏的方式来处理这个问题?
谢谢
编辑:
我认为一个解决方案是使用WriteXml。任何人都可以提供一个使用它的示例,不用写入一个文件,而是像GetXml那样获取一个字符串?感谢
问题出现在Microsoft知识库文章中:
http://support.microsoft.com/default。 aspx?scid = kb; EN-US; Q317961
问题是您没有附加到数据集的模式,指定该元素应该被写入出来
我不相信使用WriteXml会解决问题,正如文档所述,调用此方法与使用XmlWriteMode调用WriteXml相同设置为IgnoreSchema。
但是您可以自由尝试 - 以下是等价的代码:
StringWriter sw = new StringWriter();
ds.WriteXml(sw);
string outputXml = sw.ToString();
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
EDIT: 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
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.
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屋!