Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
using Microsoft.XmlDiffPatch;
            System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create("D:\\diff.xml");

            // There are a number of available options in the XmlDiffOptions enum
            XmlDiff diff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder | XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreWhitespace | XmlDiffOptions.IgnoreXmlDecl | XmlDiffOptions.IgnorePI | XmlDiffOptions.IgnoreNamespaces | XmlDiffOptions.IgnorePrefixes | XmlDiffOptions.IgnoreDtd);
             

            diff.Compare(@"D:\\registrybackup.xml", @"D:\\registrybackupthef.xml", true, writer);



i take 2 xml backup registry from two pc
when i  compare between them
i have that error


System.Xml.XmlException was unhandled
  Message='.', hexadecimal value 0x00, is an invalid character. Line 8, position 39.
  Source=System.Xml
  LineNumber=8
  LinePosition=39
  SourceUri=""
  StackTrace:
       at System.Xml.XmlTextReaderImpl.Throw(Exception e)
       at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
       at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
       at System.Xml.XmlTextReaderImpl.ParseAttributes()
       at System.Xml.XmlTextReaderImpl.ParseElement()
       at System.Xml.XmlTextReaderImpl.ParseElementContent()
       at System.Xml.XmlTextReaderImpl.Read()
       at System.Xml.XmlTextReader.Read()
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.LoadChildNodes(XmlDiffParentNode parent, XmlReader reader, Boolean bEmptyElement)
       at Microsoft.XmlDiffPatch.XmlDiffDocument.Load(XmlReader reader, XmlHash xmlHash)
       at Microsoft.XmlDiffPatch.XmlDiff.Compare(XmlReader sourceReader, XmlReader changedReader, XmlWriter diffgramWriter)
       at Microsoft.XmlDiffPatch.XmlDiff.Compare(String sourceFile, String changedFile, Boolean bFragments, XmlWriter diffgramWriter)
       at yahoo.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Sirhirbaz\documents\visual studio 2010\Projects\yahoo\yahoo\Form1.cs:line 31
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at yahoo.Program.Main() in C:\Users\Sirhirbaz\documents\visual studio 2010\Projects\yahoo\yahoo\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Thank You.
Posted
Comments
Deependra Khangarot 25-Mar-13 2:37am    
Same thread:

http://www.codeproject.com/Answers/566997/howplustopluscompareplusbetweenplus2plusxmlplusreg#answer1

Well, look at the XML standard. The character with the code point 0 is not considered as a valid character in XML.

As you did not show how you obtained the XML file and did not show any XML sample, that's all. Everything else in your question is irrelevant: the parsing code may be correct, but not the XML file.

—SA
 
Share this answer
 
sorry i forget to write sample xml backup registry







http://www.mediafire.com/?57z49pw9cz8gv77[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900