I’m writing an audit log that saves the delta between two serialized objects of the same type. Is there a way to easily prune out nodes that have the same value and leave the ones that changed?
StreamWriter oldData = new StreamWriter();
StreamWriter newData = new StreamWriter();
XmlSerializer xmlOld = new XmlSerializer(typeof(MyClass));
XmlSerializer xmlNew = new XmlSerializer(typeof(MyClass));
xmlOld.Serialize(oldData, obj);
xmlNew.Serialize(newData, obj);
Thanks.
Microsoft provides a tool ‘XMLDiffPatch’ that is pretty easy to use, and will provide the output that you are looking for. Here is a handy little guide for it.
http://msdn.microsoft.com/en-us/library/aa302294.aspx
Basically you will use the tool to identify what you should drop out from your two items and then go from there.