Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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
Posted
Comments
BillWoodruff 17-Sep-11 8:14am    
Is your question here: "how do I check an XML file (you are creating) for the presence of a Parent Node whose text/description matches a new Parent Node I am about to add" ?
Prerak Patel 19-Sep-11 0:15am    
Not clear. Rephrase your question.

1 solution

Hi,

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

C#
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900