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

Home Page Forums BizTalk 2004 – BizTalk 2010 How to compare 2 xml files using C#.net (compare only nodes..not values) Re: How to compare 2 xml files using C#.net (compare only nodes..not values)

#26226

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;

           }