I tested it with the file you provided, and it did produce wrong results. The error appeared on line 1042:
<UniqueID>CA_9445df0f3a544807af6c1527ee67f90b</UniqueID>
Using the Cast method is not enough, we also need to add the ToList method after it.
foreach (XmlNode node in nodeList.Cast<XmlNode>().ToList())
After adding this, the generated result is the same as the correct sample file.
string[] lines = File.ReadAllLines(@"C:\...\example-out-correct.xml");
string[] lines1 = File.ReadAllLines(@"C:\...\Desktop\myResult.xml");
for (int i = 0; i < lines.Count(); i++)
{
if (lines[i]!=lines1[i])
{
Console.WriteLine(i+1);
break;
}
}
Console.ReadKey();
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.