code_junkie

Creating a specific XML document using namespaces in C#

Nov 13th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Doc1 xmlns="http://www.sample.com/file" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://www.sample.com/file/long/path.xsd">
  4. <header>
  5. <stuff>data</stuff>
  6. <morestuff>data</morestuff>
  7. </header>
  8. </Doc1>
  9.  
  10. XmlDocument doc = new XmlDocument();
  11. doc.LoadXml("<Doc1></Doc1>");
  12. // Add nodes here with insert, etc...
  13.  
  14. XmlDocument doc = new XmlDocument();
  15.  
  16. XmlSchema schema = new XmlSchema();
  17. schema.Namespaces.Add("xmlns", "http://www.sample.com/file");
  18.  
  19. doc.Schemas.Add(schema);
  20.  
  21. using System.Xml.Schema;
  22. using System.Xml;
Add Comment
Please, Sign In to add comment