private static void ManipulateXDocument() { var xDocument = new XDocument(); var root = new XElement("Root"); var a = new XElement("a"); var b = new XElement("b", new XText("value")); root.Add(a, b); xDocument.Add(root); XDocumentUtilities.DisplayInConsole(xDocument, title: nameof(ManipulateXDocument)); XDocumentUtilities.SaveAsXmlFile(xDocument, title: nameof(ManipulateXDocument)); }
private static void GenerateXDocument() { var xDocument = new XDocument( new XDeclaration(version: "1.0", encoding: "utf-8", standalone: null), new XElement("ElementA", new XAttribute("Attribute", "AttributeValue"), new XElement("ElementB", new XText("ElementB_Text"), new XCData("This is CData section not recognized as XML document.") ))); XDocumentUtilities.DisplayInConsole(xDocument, title: nameof(GenerateXDocument)); XDocumentUtilities.SaveAsXmlFile(xDocument, title: nameof(GenerateXDocument)); }