top of page

XNode Performance Comparison: ToString() VS XNode.DeepEquals()

A few weeks back, I developed an XML message parser and cleaner for Healthcare CDA messages. As part of the project, I needed to do a comparison of two nodes to see if they contained the same content. For the first run, I just called XNode.ToString() on the nodes and performed a string comparison. Everything seemed to work well enough, but the memory consumption was through the roof. I ran a memory profile on my unit test and here were the results.