is there a a way to register to the changed event of the XDocument class, or the NodeChanged event of the XmlDocument class while the class is being constructed ?
the following code did not work for me (the handler was not called) :
string fileName = "MyFile.xml";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.NodeChanged += new XmlNodeChangedEventHandler(xmlDocument_NodeChanged);
xmlDocument.Load(fileName);
void xmlDocument_NodeChanged(object sender, XmlNodeChangedEventArgs e)
{
throw new NotImplementedException();
}
Form MSDN,
XObject : Events are raised only when an XML tree is modified, not when it is constructed.
I couldn't find an equally pertinent statement for XmlDocument but it seems reasonable not to raise NodeChanged on creation. You might try NodeInserted.
I just tried, NodeInserting and NodesInserted are firing during Load()
.