I have a DataSet with data that I output (write) to an XMl file.
I have added a namespace and prefix to the dataset like this:
public static string XmlNamespace = "http://namespace";
public static string XmlPrefix = "ns0";
RequestDataSet.Namespace = XmlNamespace;
RequestDataSet.Prefix = XmlPrefix;
The XML output is as follows:
<?xml version="1.0" standalone="yes"?>
<ns0:list xmlns:ns0="http://namespace">
<ns0:item xmlns="http://namespace">
<data1>1234</data1>
<data2>91011</data2>
</item>
</ns0:list>
But it should be like this: (no namespace on the item records. Just the prefix)
<?xml version="1.0" standalone="yes"?>
<ns0:list xmlns:ns0="http://namespace">
<ns0:item>
<data1>1234</data1>
<data2>91011</data2>
</item>
</ns0:list>
I have tried setting the tables prefix/namespace to null like this:
RequestDataSet.Tables["item"].Prefix = XmlPrefix;
RequestDataSet.Tables["item"].Namespace = null;
But that also does not work… Does anyone know a solution for this?
I’ve come across similar issues when fighting with BizTalk adapters… but that’s a different story.
Not sure if there is a different (cleaner) way, but you could always ‘grab’ the attribute and remove it, as decribed here.
Effectively you would do the following: