XMLDocument.Importnode fails



i´m currently working on a Project where i have to create XMLNodes and insert them at specific places in the XML File.


The XMLNode is a Row with around 90 Cells.



<Row ss:AutoFitHeight=\"0\">"
<Cell ss:StyleID=\"s77\"><Data ss:Type=\"String\">ABC</Data></Cell>
<Cell><Data ss:Type=\"Number\">100</Data></Cell>
<Cell ss:StyleID=\"s77\"><Data ss:Type=\"String\">ABC</Data></Cell>
<Cell><Data ss:Type=\"String\" x:Ticked=\"1\">&#45;&#45;-</Data></Cell>
</Row>


I create the Document via Stringbuilder and read them in with:



using (StringReader sr = new StringReader((sbuilder.ToString())))
using (XmlTextReader xtr = new XmlTextReader(sr) { Namespaces = false })
{
xdoc.Load(xtr);
}


The XML File where i want to add my nodes is an Excel 2003 Sheet with 3 Tabs but i only Need the first one. I load it in with:



XmlDocument xtemplate = new XmlDocument();
xtemplate.Load(file);


and try to Import my Node into the Template XML



XmlNode tempnode = xtemplate.ImportNode(xdoc.DocumentElement, true);


And here i get an XmlException



The ':' - characters Hex value 0x3A, shall not be included in a name.



I don´t have a clue where this is comming from. No cell or row gets a custom name and i could not find a name which contained anything but letters (Except the document which has '#document' as Name)


I hope someone has experienced this Exception too and could help me understand it so i can solve my problem.




I hope you can understand what my Problem is, if not i will try my best to explain it better. My English is a bit rusty so pleasy have mercy if i butchered it.


No comments:

Post a Comment