请教数组的序列化问题。(50分)
使用如下代码序列化一个字符串数组:
得到sss的内容是:
<root xmlns:d1p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d1p1:string>aa</d1p1:string>
<d1p1:string>bbb</d1p1:string>
</root>
请问,如何才能把默认的命名空间去掉呢?
我希望得到的结果是:
<root xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<string>aa</string>
<string>bbb</string>
</root>
等待高手指教。 谢谢。
string[] a = new string[] { "aa", "bbb" };
DataContractSerializer ser = new DataContractSerializer(typeof(string[]), "root", "");
using (MemoryStream ms = new MemoryStream())
{
ser.WriteObject(ms, a);
ms.Position = 0;
using (StreamReader reader = new StreamReader(ms))
{
string sss = reader.ReadToEnd();
}
}
得到sss的内容是:
<root xmlns:d1p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d1p1:string>aa</d1p1:string>
<d1p1:string>bbb</d1p1:string>
</root>
请问,如何才能把默认的命名空间去掉呢?
我希望得到的结果是:
<root xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<string>aa</string>
<string>bbb</string>
</root>
等待高手指教。 谢谢。
...全文
相关推荐
C# 数组与序列化
C# 数组与序列化C# 数组与序列化C# 数组与序列化C# 数组与序列化C# 数组与序列化C# 数组与序列化C# 数组与序列化
C# 读取序列化后的数组
C# 读取序列化后的数组C# 读取序列化后的数组C# 读取序列化后的数组C# 读取序列化后的数组C# 读取序列化后的数组
asp.net 数组与序列化
asp.net 数组与序列化! 很值得下载看看!资源免费,大家分享!!
asp.net 读取序列化后的数组
asp.net 读取序列化后的数组! 很值得下载看看!资源免费,大家分享!!
C#中二进制数组转换,二进制序列化和json序列化方法
C#中二进制数组h和各种常规数组的转换,二进制序列化和json序列化方法以及对应的反序列化方法的例子,帮助初学者。


