How can I remove an empty namespace with XElement ?
Using the below code I wish to apply the namespace only to the root node
<urlsetbut I obtain also an empty xmlns="" on the child nodes.
Thanks
Sandro
XNamespace ns = "http://www.sitemaps.or g/schemas/sitemap/0.9";
XElement elRoot = new XElement(ns + "urlset",
new XElement ("url",
new XElement ("loc", "someurl... ")
),
new XElement ("url",
new XElement ("loc", "someurl... ")
)
);
XDocument doc = new XDocument(
new XDeclaration("1 .0", "utf-8", "yes"),
elRoot
);
doc.Save(Consol e.Out);
Console.ReadLin e();
Result:
<?xml version="1.0" encoding="ibm85 0" standalone="yes "?>
<urlset xmlns="http://www.sitemaps.or g/schemas/sitemap/0.9">
<url xmlns="">
<loc>someurl... </loc>
</url>
<url xmlns="">
<loc>someurl... </loc>
</url>
</urlset>