Google Answers Logo
View Question
 
Q: code that compare to xml files ( No Answer,   1 Comment )
Question  
Subject: code that compare to xml files
Category: Computers > Programming
Asked by: sharon_de_salmon-ga
List Price: $2.00
Posted: 04 Nov 2004 00:27 PST
Expires: 04 Dec 2004 00:27 PST
Question ID: 424247
where can I find a ready to you code that compare to xml files (or
strings) and show the diffrence in an xml semantics (i.e. show which
node/ attributes are diffrerent , the difference and the fuul xml path
to that node).
the code need to be in c# as a class function or c# code that can be
copied to a class .
I want somthing I can use that look about this :

XMLComparer Xcomp = new XMLComparer();
string res = Xcomp.compare(XMLfile1,XMLfile2);

Request for Question Clarification by endo-ga on 04 Nov 2004 06:58 PST
Hi,

Can you please tell me if the following code works for you:

START CODE

XmlDocument doc = new XmlDocument();
doc.Load("One.xml");
XPathDocument doc2 = new XPathDocument("Two.xml");
XPathNavigator nav = doc2.CreateNavigator();
foreach (XmlNode msg in doc.SelectNodes("//Message")) {
  XPathNodeIterator ni = nav.Select("/Result[MessageID='" +           
    msg.SelectSingleNode("MessageID/text()").Value +               
"']/ResultCode");
ni.MoveNext();
if (ni.Current.Value == "Error")
    msg.ParentNode.RemoveChild(msg);
}
//Resulting document
doc.Save(Console.Out);


END CODE

Thanks.
endo

Clarification of Question by sharon_de_salmon-ga on 04 Nov 2004 08:05 PST
I tried the following code one 2 identical xlm files and instead of getting
an empty result i got the whole xml as result.

Clarification of Question by sharon_de_salmon-ga on 04 Nov 2004 08:07 PST
I tried the code on 2 identical xml files , and instead of getting an
empty result i got the whole xml as result, why ????

Request for Question Clarification by endo-ga on 04 Nov 2004 08:18 PST
Hi,

Can you try changing the bit that says
ni.Current.Value == "Error"
to
ni.Current.Value != "Error"
or
!ni.Current.Value == "Error"

Thanks.
endo

Clarification of Question by sharon_de_salmon-ga on 04 Nov 2004 23:27 PST
I tried it I changed to: ni.Current.Value != "Error"
but still did not get an empty result
Answer  
There is no answer at this time.

Comments  
Subject: Re: code that compare to xml files
From: hvishwanatham-ga on 08 Nov 2004 13:25 PST
 
Refer http://www.topxml.com/forum/m_928/mpage_1/key_//tm.htm#1036

Let me know if it helps u..

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy