// Open the XML doc
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.Load(Server.MapPath("AddProducts.xml"));
XmlNode myXmlNode = myXmlDocument.DocumentElement.FirstChild;
// Create new XML element and populate its attributes
XmlElement myXmlElement = myXmlDocument.CreateElement("product");
myXmlElement.SetAttribute("name", Server.HtmlEncode(txtname.Text));
// Insert data into the XML doc and save
myXmlDocument.DocumentElement.InsertBefore(myXmlElement, myXmlNode);
myXmlDocument.Save(Server.MapPath("AddProducts.xml"));
My XML file is:
<?xml version="1.0" encoding="utf-8"?>
<Footballers>
<product name="iop" />
<product name="Selvit E" />
<product name="Selvit E" />
<product name="Ventrifort A" />
<product name="Generator" />
<product name="TEst" />
<product name="test" />
<product name="Test" />
<product name="test" />
<product name="ILT" />
<product name="No Parking" />
<product name="No Parking" />
<product name="Livol Liquid" />
<product name="G-promin" />
</Footballers>
In my xml file stores duplicate values. I don't want to store duplicate values. How can i do this?
No comments:
Post a Comment