且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 C# 中使用命名空间创建特定的 XML 文档

更新时间:2023-11-24 17:49:04

你应该这样试试

  XmlDocument doc = new XmlDocument();  

  XmlSchema schema = new XmlSchema();
  schema.Namespaces.Add("xmlns", "http://www.sample.com/file");

  doc.Schemas.Add(schema);

不要忘记包含以下命名空间:

Do not forget to include the following namespaces:

using System.Xml.Schema;
using System.Xml;