Creating a specific XML document using namespaces in C#

前端 未结 3 1765
野的像风
野的像风 2020-12-03 08:01

We were given a sample document, and need to be able to reproduce the structure of the document exactly for a vendor. However, I\'m a little lost with how C# handles namesp

3条回答
  •  死守一世寂寞
    2020-12-03 08:56

    You should try it that way

      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;
    

提交回复
热议问题