I have to create an xml in which i need to add namespace to the root of the xml
I have created the whole xml using XDocument only having the trouble in adding the namespace.
I have to add namespace to the root so that it is somewhat like
<railml version="2.0" xmlns="http://www.railml.org/schemas/2009" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd">
Now I am creating the xml using xdocument somewhat like this:
var doc = new XDocument(new XElement("railml"));
var root = doc.Root;
XAttribute ver = new XAttribute("version", "2.0");
root.Add(ver);
How can i add the namespaces with xdocument..
please suggest a such solution that i don't need to disturb the current way by which i am generating the xml.