XElement Add function adds xmlns="" to the XElement
- by JJoos
I have a function which generates xml for a list object:
public XDocument ToXML()
{
foreach (var row in this)
{
var xml = row.ToXml();
template.Root.Add(xml);
}
return template;
}
The template.ToString() reads: <RootElement xmlns="urn:testTools">
The xml reads: <Example><SubElement>testData</SubElement></Example>
After the add function has executed the template.ToString() reads: <RootElement xmlns="urn:testTools"><Example xmlns=""><SubElement>testData</SubElement></Example>
So for some reason there was an empty namespace added, how can i prevent it from doing so?