Example #1
0
        private static void IndentXml(XElement element, int depth)
        {
            element.AddBeforeSelf(new XText(DirectXmlSaveFormatter.IndentString(depth, true)));
            bool startWithNewline = element.NextNode == null;

            element.AddAfterSelf(new XText(DirectXmlSaveFormatter.IndentString(depth - 1, startWithNewline)));
            foreach (XElement element2 in element.Elements().ToList <XElement>())
            {
                DirectXmlSaveFormatter.IndentXml(element2, depth + 1);
            }
        }
Example #2
0
 public static void AddWhitespaceFromRoot(XElement root)
 {
     if (root.Elements().Any())
     {
         foreach (XElement item in root.Elements().ToList())
         {
             XText content = new XText("\n");
             item.AddAfterSelf(content);
         }
         root.Elements().First().AddBeforeSelf(new XText("\n"));
         root.Elements().Last().AddAfterSelf(new XText("\n"));
         foreach (XElement item2 in root.Elements().ToList())
         {
             DirectXmlSaveFormatter.IndentXml(item2, 1);
         }
     }
 }
Example #3
0
 public static void AddWhitespaceFromRoot(XElement root)
 {
     if (!root.Elements().Any <XElement>())
     {
         return;
     }
     foreach (XElement xelement in root.Elements().ToList <XElement>())
     {
         XText content = new XText("\n");
         xelement.AddAfterSelf(content);
     }
     root.Elements().First <XElement>().AddBeforeSelf(new XText("\n"));
     root.Elements().Last <XElement>().AddAfterSelf(new XText("\n"));
     foreach (XElement element in root.Elements().ToList <XElement>())
     {
         DirectXmlSaveFormatter.IndentXml(element, 1);
     }
 }