在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
来源:互联网 发布:d3.js 实现网络拓扑图 编辑:程序博客网 时间:2024/05/22 14:59
原文地址:在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi作者:VanHelsing
可使用以下代码:
//Create our own namespaces for the outputXmlSerializerNamespaces ns = new XmlSerializerNamespaces (); //Add an empty namespace and empty valuens.Add ("", ""); //Create the serializerXmlSerializer slz = new XmlSerializer (someType); //Serialize the object with our own namespaces (notice the overload)slz.Serialize (myXmlTextWriter, someObject, ns);
此外,在评论中还提到了去除开头的<?xml version="1.0" encoding="utf-8"?>的方法:
XmlWriterSettings settings = new XmlWriterSettings (); // Remove the <?xml version="1.0" encoding="utf-8"?>settings.OmitXmlDeclaration = true; XmlWriter writer = XmlWriter.Create ("output_file_name.xml", settings); 另外,如果出现开头没有encoding="utf-8"时,应该使用: XmlWriterSettings settings = new XmlWriterSettings ();settings.Encoding = Encoding.UTF8; XmlWriter writer = XmlWriter.Create ("output_file_name.xml", settings);
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- web.xml开头<web-app>中的xmlns、xsi、schemaLocation、xsd等,命名空间
- xmlns:XML命名空间
- xml文件参照XSD时开始部分中的xmlns:和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- XML文档的xmlns、xmlns xsi和xsi schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- XML文档中的xmlns、xmlns:xsi和xsi:schemaLocation理解
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- 关于XML文档的xmlns、xmlns:xsi和xsi:schemaLocation
- asp 通用防止注入
- Poweershell 用来添加邮箱
- DSP系统关于C编程
- 分布式文件系统KFS源码阅读与分析(二):MetaServer元数据持久化
- 忘记fedora的root密码
- 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi
- 分布式文件系统KFS源码阅读与分析(一):MetaServer元数据组织结构
- Ubuntu10.04 添加中文输入法,设置开机自动启动
- 分布式文件系统KFS源码编译与安装过程
- 分布式文件系统KFS基础知识介绍
- c++ 链接时出现错误
- 分布式文件系统KFS源码阅读与分析(三):RPC实现机制(MetaServer端)
- 每天一道编程题(三)------插入排序
- DSP多线程