Comparing XmlDocument for equality (content wise)

后端 未结 5 2015
情深已故
情深已故 2020-12-18 19:38

If I want to compare the contents of a XMlDocument, is it just like this?

XmlDocument doc1 = GetDoc1();
XmlDocument doc2 = GetDoc2();

if(doc1 == doc2)
{

}
         


        
5条回答
  •  长情又很酷
    2020-12-18 20:27

    Try the DeepEquals method on the XLinq API.

    XDocument doc1 = GetDoc1(); 
    XDocument doc2 = GetDoc2(); 
    
    if(XNode.DeepEquals(doc1, doc2)) 
    { 
    
    } 
    

    See also Equality Semantics of LINQ to XML Trees

提交回复
热议问题