如何比较两个XML节点? [英] How to compare two xml nodes?

查看:373
本文介绍了如何比较两个XML节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的XML节点有6个属性,但事情是从这些属性,我需要检查的天气2属性等于或不。如果相等则应该省略,​​否则入境必须写在XML文件中

My XML node have 6 attributes but the thing is from these attributes I need to check weather 2 attributes are equal or not. If equal then the the entry should be omitted otherwise must be written in XML file

我想code

private static bool checkDuplication(XmlElement Xtemp, XmlNodeList xmlNodeList)
{
    foreach (XmlNode node in xmlNodeList)
    {
        for (int i = 0; i < ComparableAttributes.Count(); i++)
        {
            if (node == Xtemp)
            {
                return true;
            }
        }
     }
     return false;
}

它不工作!

推荐答案

据我所知,你不能修改的web.config 在运行时,因为当它被改变,你的应用程序将重新启动。

As far as I know, you cannot modify web.config at runtime, since when it is changed, your Application restarts.

另外,我不知道,但我觉得想比较的XmlNode和XmlElement的简单的==将无法正常工作,因为它只比较引用,而不是对象的内容。

In addition, I'm not sure, but I think think comparing XmlNode and XmlElement with simple == will not work since it compares references only and not objects content

这篇关于如何比较两个XML节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆