fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. using System.Xml;
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. public static void Main(string[] args)
  11. {
  12. var doc = new XmlDocument();
  13. var stream = new MemoryStream();
  14.  
  15. XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "utf-8", null);
  16. XmlElement rootNode = doc.CreateElement("rexim");
  17. rootNode.InnerText = "давлоыдаывалдыовадлы";
  18. rootNode.SetAttribute("xmlns", "rexim:coding-team:test");
  19. doc.InsertBefore(xmlDeclaration, doc.DocumentElement);
  20. doc.AppendChild(rootNode);
  21.  
  22. XmlWriterSettings settings = new XmlWriterSettings()
  23. {
  24. Indent = true
  25. };
  26.  
  27. using( var writer = XmlWriter.Create(stream,settings)) {
  28. doc.Save(Console.Out);
  29. }
  30. }
  31. }
  32. }
  33.  
Success #stdin #stdout 0.09s 24424KB
stdin
Standard input is empty
stdout
<?xml version="1.0" encoding="utf-8"?>
<rexim xmlns="rexim:coding-team:test">давлоыдаывалдыовадлы</rexim>