我想比较两个 xml 文件并找出它们的异同,
private void checkLanguage(string file1, string file2)
{
XmlDocument xmldoc1 = new XmlDocument();
XmlDocument xmldoc2 = new XmlDocument();
XmlNodeList xmlnode1;
XmlNodeList xmlnode2;
int i = 0;
int j = 0;
string str = null;
FileStream fs1 = new FileStream(file1, FileMode.Open, FileAccess.Read);
xmldoc1.Load(fs1);
FileStream fs2 = new FileStream(file2, FileMode.Open, FileAccess.Read);
xmldoc2.Load(fs2);
xmlnode1 = xmldoc1.GetElementsByTagName("data");
xmlnode2 = xmldoc2.GetElementsByTagName("data");
for (i = 0; i <= xmlnode1.Count - 1; i++)
{
str = xmlnode1[i].Attributes["name"].Value;
for (j = 0; j <= xmlnode2.Count - 1; j++)
{
if (str == xmlnode2[j].Attributes["name"].Value)
{
lblResult.ForeColor = Color.Green;
lblResult.Text += Environment.NewLine + xmlnode1[i].Attributes["name"].Value;
}
else
{
label4.ForeColor = Color.Red;
label4.Text += Environment.NewLine + xmlnode1[i].Attributes["name"].Value;
}
}
}
}
我的问题是差异字段中两个xml文件列表中的类似语言也是..如何解决这个问题..
有人能帮我吗?谢谢