I am creating an xml document from Sql Server data using C# and XElement and the client spec requires an attribute namespace xmlns in the main tag (case is the main tag). Here is the example from their spec:
<case techname="Client" count="4" xmlns="http://tempuri.org/NBAppSchema.xsd">
My problem is that I am getting an error in C# trying to output this 'case' tag's xmlns attribute with using a prefix. (error: The prefix '' cannot be redefined from '' to 'http://example.com/xmlns1' within the same start element tag.)
When I include a prefix, it generates the xml fine only the client tells me that when they try to load it, it errors out. Example with prefix:
<case techname="Client" count="4" xmlns:prfx="http://tempuri.org/NBAppSchema.xsd">
Code:
XNamespace ns = "http://tempuri.org/NBAppSchema.xsd";
XElement mainCaseTag = new XElement("case", new XAttribute("techname", "Univers"), new XAttribute("count", totalApplicationCount), new XAttribute(XNamespace.Xmlns + "prfx", ns));
I would like to output this attribute as the first example without the prefix. I have tried to research, but cannot find or understand how to output this xml file with a namespace without the prefix.