Beispiel #1
0
        public static XDocument Create(Encoding encoding, bool standAlone, float version, params object[] content)
        {
            XDocument document = new XDocument();

            document.AppendDeclaration(encoding, standAlone, version);
            if (!content.IsNullOrEmpty())
            {
                document.Add(content);
            }
            return(document);
        }
        public static XDocument ToXDocument([NotNull] this XmlDocument thisValue)
        {
            XDocument document = new XDocument();

            using (XmlWriter xmlWriter = document.CreateWriter())
                thisValue.WriteTo(xmlWriter);

            XmlDeclaration decl = thisValue.ChildNodes.OfType <XmlDeclaration>().FirstOrDefault();

            if (decl != null)
            {
                document.AppendDeclaration(decl);
            }
            return(document);
        }