Iam using the WriteXml() of a dataset to save the data I have in the dataset to an XML. 开发者_JAVA百科When I save the dataset value into the XML file the format of the file is like code below.
I save the dataset like this: Order_Dataset.WriteXml(@"C:\Orders", XmlWriteMode.IgnoreSchema)
How can I write so that the XMLNS adress dose not shows in my XML file?? XmlWriteMode.IgnoreSchema should do the work but it wont
<Order_Dataset xmlns="http://tempuri.org/Order_Dataset.xsd">
<Order>
<OrderName>Coffe</OrderName>
<OrderID>1</OrderID>
<OrderDate>2011-02-20T14:11:21+01:00</OrderDate>
</Order>
Have you tried changing the namespace of DataSet before saving it?
DataSet ds = new DataSet("MyDataSet");
ds.Namespace = "";
ds.WriteXml(...);
DataSet has internal variable fTopLevelTable that is changed only if a XML file is loaded. Use debugger to see difference after you load your hand changed XML into... This does the trick if you create DataSet by code or with ReadXmlSchema().
FieldInfo fieldInfo = typeof(DataSet).GetField("fTopLevelTable", BindingFlags.NonPublic | BindingFlags.Instance);
fieldInfo.SetValue(yourDS, true);
精彩评论