Taylor_Indiana
New Member
I am trying to use xmldiffpatch when comparing two Xmls(one from a stream, the other from a file) and writing the diff patch to a stream.The first method is to write my xml to a memory stream.The second method loads an xml from a file and creates a stream for the patched file to be written into. The third method actually compares the two files and writes the third. The \[code\]xmldiff.Compare(originalFile, finalFile, dgw);\[/code\] method takes (XmlReader, XmlReader, XmlWriter). I'm always getting that both files are identical, even though they are not, so I know that I am missing something. Any help is appreciated!\[code\]public MemoryStream FirstXml() { string[] names = { "John", "Mohammed", "Marc", "Tamara", "joy" }; MemoryStream ms = new MemoryStream(); XmlTextWriter xtw= new XmlTextWriter(ms, Encoding.UTF8); xtw.WriteStartDocument(); xtw.WriteStartElement("root"); foreach (string s in names) { xtw.WriteStartElement(s); xtw.WriteEndElement(); } xtw.WriteEndElement(); xtw.WriteEndDocument(); return ms; } public void SecondXml() { XmlReader finalFile =XmlReader.Create(@"c:\......\something.xml"); MemoryStream ms = FirstXml(); XmlReader originalFile = XmlReader.Create(ms); MemoryStream ms2 = new MemoryStream(); XmlWriter dgw = XmlWriter.Create(ms2); Comparison(originalFile, finalFile, dgw); } public void Comparison(XmlReader originalFile, XmlReader finalFile, XmlWriter dgw) { XmlDiff xmldiff = new XmlDiff(); bool bIdentical = xmldiff.Compare(originalFile, finalFile, dgw); dgw.Close(); StreamReader sr = new StreamReader(); string xmlOutput = sr.ReadToEnd(); if(xmlOutput.Contains("</xd:xmldiff>") System.Windows.Forms.MessageBox.Show("Xml files are not identical"); else System.Windows.Forms.MessageBox.Show("Xml files are identical");}\[/code\]