不要添加重复的节点 [英] don't add a duplicate node

查看:115
本文介绍了不要添加重复的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个xml文件,其父节点是通过单击按钮时的textbox.text创建的.如果textbox.text再次包含已作为xml文件的父节点包含的文本.它会在标签上显示错误,在运行时可见性为假.

感谢

hi guys,


I have a xml file which Parent Node is created by textbox.text on button click. if textbox.text is again include a text which is already include as a parent node in xml file. it gives a error on label which visibility is false at run time.

thanks

推荐答案



此处" m提供了一些代码,以供您在xml中输入现有标签时显示一些错误

Hi,

here ''m providing some code to display some error while you entered existing tag in xml

protected void Button1_Click(object sender, EventArgs e)
{
    XmlDocument xmldoc = new XmlDocument();
    xmldoc.Load(Server.MapPath ("~/SomeFiles/XMLFile2.xml"));
    XmlNodeList xmlnodli = xmldoc.GetElementsByTagName(TextBox1.Text);
    if (xmlnodli.Count > 0)
    {
        Label1.Text = "your enter tag is already exists";
        Label1.Visible = true;
    }
}



希望这段代码对您有所帮助.

一切顺利



I hope this code helps you.

All the best


这篇关于不要添加重复的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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