xml 序列化时, 去掉默认的命名空间
2009-03-11 17:25
525 查看
C# 的 xml 序列化时,文档总会带有
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
and
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
如果想去掉,或者添加自己的命名空间,可以考虑下面的做法
参考:http://www.csharper.net/blog/serializing_without_the_namespace__xmlns__xmlns_xsd__xmlns_xsi_.aspx
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
and
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
如果想去掉,或者添加自己的命名空间,可以考虑下面的做法
//Create our own namespaces for the output XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); //Add an empty namespace and empty value ns.Add("", ""); //Create the serializer XmlSerializer slz = new XmlSerializer(someType); //Serialize the object with our own namespaces (notice the overload) slz.Serialize(myXmlTextWriter, someObject, ns);
参考:http://www.csharper.net/blog/serializing_without_the_namespace__xmlns__xmlns_xsd__xmlns_xsi_.aspx
相关文章推荐
- 【转】C# XML序列化去掉XML默认的命名空间及声明头
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- [zt]在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 序列化object成xml并且去掉命名空间
- C# XML序列化去掉XML默认的命名空间及声明头
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- .Net 序列化(去除默认命名空间,添加编码)
- C# 加载XML 文件 去掉注释 和命名空间
- .Net 序列化(去除默认命名空间,添加编码)
- XML 默认命名空间
- .Net 序列化(去除默认命名空间,添加编码)
- C# 中的默认命名空间的范围 (LINQ to XML)
- 去掉xml中的命名空间
- struts.xml配置文件中的包,命名空间,默认继承的介绍
- xpath对带默认命名空间的xml节点的定位
- [玩转微信平台]XML的格式化- 如何去掉XML 文档头和命名空间