I want to create a Xml file that looks something like this:
<Root xmlns:ns1="name1" xmlns:ns2="name2">
<ns1:element1 />
<ns1:element2 />
<ns2:element3 />
</Root>
How can I accomplish this using XAttribute, XElement, XNamespace, and XDocument where the namespaces are dynamically added.
I assume by "namespaces are dynamically added" you mean the namespace prefix. This generates the document, how close is it to what you meant?