private static XElement GetOrCreateBody(XDocument document)
        {
            var documentBody = document.GetBody();

              if (documentBody == null)
              {
            var htmlElement = document.GetChildrenByTagName("html").FirstOrDefault();

            if (htmlElement == null)
            {
              htmlElement = new XElement("html");
              document.Add(htmlElement);
            }

            documentBody = new XElement("body");
            htmlElement.Add(documentBody);
              }

              return documentBody;
        }
예제 #2
0
using System;