Mega Code Archive

 
Categories / C# / XML LINQ
 

Two namespaces

using System; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XNamespace aw = "http://www.domain.com";         XNamespace fc = "www.anotherDomain.com";         XElement root = new XElement(aw + "Root",             new XAttribute("xmlns", "http://www.domain.com"),             new XAttribute(XNamespace.Xmlns + "fc", "www.anotherDomain.com"),             new XElement(fc + "Child",                 new XElement(aw + "DifferentChild", "other content")             ),             new XElement(aw + "Child2", "c2 content"),             new XElement(fc + "Child3", "c3 content")         );         Console.WriteLine(root);     } }