Using an XmlDataDocument together with DataSet (typed)
Doing some loads and ImportNode/AppendChild
So far so good, but when I do some ImportNode/ReplaceChild, the problem
starts.
Code snippet:
:
XmlDataDocument destinationDoc;
destinationDoc = new XmlDataDocument(myTypedDataset);
:
destinationDoc.DataSet.EnforceConstraints = false;
XmlDocument sourceDoc = new XmlDocument();
sourceDoc.LoadXml(aString);
XmlElement importElement =
(XmlElement)destinationDoc.ImportNode(sourceDoc.DocumentElement, true);
XmlElement destinationElement =
(XmlElement)destinationDoc.DocumentElement.SelectSingleNode(path, nsmgr);
destinationElement.ParentNode.ReplaceChild(importElement,
destinationElement);
This last codeline throws the RowNotInTableException with additional info:
"This row has been removed from a table and does not have any data.
BeginEdit() will allow creation of new data in this row"
I understand that a row (representing my destinationElement) has been
deleted, but it must be deleted because I want to replace it with another
element (and thereby another row (and possibly childrows)).
Anyone knows how to fix ?