Integrating Integrators – BizTalk, Windows Azure, Windows Workflow, and Beyond

Re: How to compare 2 xml files using C#.net (compare only nodes..not values)

BizTalk 2010

This group is for all content related to BizTalk Server 2010. This includes a forum and samples.

How to compare 2 xml files using C#.net (compare only nodes..not values)

Not Answered This question is not answered

How to compare 2 xml files in C#.net and need to compare only nodes..not values

Edit
All Replies
  • load the file in xml doc and than

    if (doc.InnerXml.Length != doc2.InnerXml.Length)

               {

                 return false;

               }

    • Not Ranked
  • Xdoc1 and Xdoc2 are the XML's you want to compare and nodesnotfound gives you the list of nodes from xdoc1 not found in xdoc2.

    I just  wrote few lines quickly...test it properly.

    List<string> nodesnotFound = new List<string>();

               bool nodefound = false;

               foreach (XmlNode xnode1 in xdoc1)

               {

                   foreach (XmlNode xnode2 in xdoc2)

                   {

                       if (xnode1.Name == xnode2.Name)

                           nodefound = true;

                   }

                   if (!nodefound)

                   {

                       nodesnotFound.Add(xnode1.Name);

                   }

                   nodefound = false;

               }

    Regards,
    NISHIL
    MCT,MCTS | Freelance BizTalk Consultant.
    biztalkconnect.blogspot.com

    • Top 25 Contributor
Page 1 of 1 (3 items)