Before actually creating a node you can check if there's any duplicate existing using XPathExpression.
XmlDocument myXmlDocument = new System.Xml.XmlDocument();
myXmlDocument.Load("XMLFile1.xml");
XmlNode myXmlNode = myXmlDocument.DocumentElement.FirstChild;
string expression = string.Format(@"/Footballers/product[@name = ""{0}""]", Server.HtmlEncode(txtname.Text));
XmlNodeList existingNodes = myXmlDocument.SelectNodes(expression);
if (existingNodes.Count == 0)
{
XmlElement myXmlElement = myXmlDocument.CreateElement("product");
myXmlElement.SetAttribute("name", Server.HtmlEncode(txtname.Text));
myXmlDocument.DocumentElement.InsertBefore(myXmlElement, myXmlNode);
}
Using Xpath expression will allow you a good range of filters to filter your nodes.
Have a look at
XPath Tutorial[
^]