1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
protected void ButtonClick_Ajouter(object sender, EventArgs e)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("fichier.xml"));
XmlElement newelement = xmldoc.CreateElement("item");
XmlElement xmltitle = xmldoc.CreateElement("title");
XmlElement xmllink = xmldoc.CreateElement("link");
XmlElement xmldescription = xmldoc.CreateElement("description");
XmlElement xmlauthor = xmldoc.CreateElement("author");
XmlElement xmlcategory = xmldoc.CreateElement("category");
XmlElement xmlcomments= xmldoc.CreateElement("comments");
XmlElement xmlpubdate = xmldoc.CreateElement("pubDate");
XmlElement xmlsource = xmldoc.CreateElement("source");
xmltitle.InnerText = this.TextBoxTitle.Text.Trim();
xmllink.InnerText = this.TextBoxLink.Text.Trim();
xmldescription.InnerText = this.TextBoxDescription.Text.Trim();
xmlauthor.InnerText = this.TextBoxAuthor.Text.Trim();
xmlcategory.InnerText = this.TextBoxCategory.Text.Trim();
xmlcomments.InnerText = this.TextBoxComments.Text.Trim();
xmlpubdate.InnerText = this.TextBoxPubDate.Text.Trim();
xmlsource.InnerText = this.TextBoxSource.Text.Trim();
newelement.AppendChild(xmltitle);
newelement.AppendChild(xmllink);
newelement.AppendChild(xmldescription);
newelement.AppendChild(xmlauthor);
newelement.AppendChild(xmlcategory);
newelement.AppendChild(xmlcomments);
newelement.AppendChild(xmlpubdate);
newelement.AppendChild(xmlsource);
xmldoc.DocumentElement.AppendChild(newelement);
xmldoc.Save(Server.MapPath("fichier.xml"));
modif_fluxRSS();
loadXmlData();
ButtonClick_Clear(sender, e);
}
protected void ButtonClick_Modifier(object sender, EventArgs e)
{
if (selectIndex == -1)
{
this.RegisterClientScriptBlock("alertmessage", "<script>alert('please select one modify data item.')</script>");
}
else
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("fichier.xml"));
XmlNode xmlnode = xmldoc.DocumentElement.ChildNodes.Item(selectIndex);
xmlnode["title"].InnerText = this.TextBoxTitle.Text.Trim();
xmlnode["link"].InnerText = this.TextBoxLink.Text.Trim();
xmlnode["description"].InnerText = this.TextBoxDescription.Text.Trim();
xmlnode["author"].InnerText = this.TextBoxAuthor.Text.Trim();
xmlnode["category"].InnerText = this.TextBoxCategory.Text.Trim();
xmlnode["comments"].InnerText = this.TextBoxComments.Text.Trim();
xmlnode["pubDate"].InnerText = this.TextBoxPubDate.Text.Trim();
xmlnode["source"].InnerText = this.TextBoxSource.Text.Trim();
xmldoc.Save(Server.MapPath("fichier.xml"));
modif_fluxRSS();
loadXmlData();
ButtonClick_Clear(sender, e);
}
} |