We have a XML File with different Namespaces, you can see it below, and i would like to bind the xml file to the XmlDataProvider. The Namespaces need to be removed, otherwise i cannot load the xml into the data source. Problem:
An unhandled exception of type 'System.Xml.XmlException' occurred in System.Xml.dll
Additional information: Data at the root level is invalid. Line 1, position 1.
This is my XML and the Binding Code:
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.04" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.054.001.04 camt.054.001.04.xsd">
<Grid.DataContext>
<XmlDataProvider x:Name="xdata" XPath="//RmtInf/Strd/CdtrRefInf" >
</XmlDataProvider>
</Grid.DataContext>
The Data Load works fine, and it shows the right Values, but i cannot safe the File, because:
An unhandled exception of type 'System.ArgumentException' occurred in System.Xml.dll
Additional information: The 'xmlns' attribute is bound to the reserved namespace 'http://www.w3.org/2000/xmlns/'.
This is my code to load the XML:
XmlDocument d = new XmlDocument();
using (XmlTextReader tr = new XmlTextReader(filePath))
{
tr.Namespaces = false;
d.Load(tr);
}
xdata.Document = d;
xdata.Refresh();
Do I need to add the namespaces again? Just a default or a special one? Thanks for your help and your feedback.