protected void DetailsView2_ItemInserting(object sender, DetailsViewInsertEventArgs e) { XmlDocument xdoc = XmlDataSource4.GetXmlDocument(); XmlElement FeedsList = xdoc.SelectSingleNode("/feeds") as XmlElement; XmlElement checkFeed = xdoc.SelectSingleNode("/feeds/feed[@name='" + e.Values["name"].ToString() + "']") as XmlElement; if (checkFeed == null) { XmlElement oFeed = xdoc.CreateElement("feed"); XmlAttribute name = xdoc.CreateAttribute("name"); XmlAttribute url = xdoc.CreateAttribute("url"); name.Value = e.Values["name"].ToString(); url.Value = e.Values["url"].ToString(); oFeed.Attributes.Append(name); oFeed.Attributes.Append(url); FeedsList.AppendChild(oFeed); XmlDataSource4.Save(); e.Cancel = true; } Response.Redirect(Request.RawUrl); }
protected void DeleteFeed_Command(object sender, CommandEventArgs e) { XmlDocument xdoc = XmlDataSource4.GetXmlDocument(); XmlElement oFeed = xdoc.SelectSingleNode("/feeds/feed[@name='" + e.CommandArgument + "']") as XmlElement; xdoc.DocumentElement.RemoveChild(oFeed); xdoc.Save(Server.MapPath(XmlDataSource4.DataFile)); Response.Redirect(Request.RawUrl); }
protected void DetailsView2_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { XmlDocument xdoc = XmlDataSource4.GetXmlDocument(); XmlElement oFeed = xdoc.SelectSingleNode("/feeds/feed[@name='" + e.CommandArgument + "']") as XmlElement; oFeed.Attributes["url"].Value = e.NewValues["url"].ToString();; XmlDataSource4.Save(); e.Cancel = true; DetailsView2.ChangeMode(DetailsViewMode.ReadOnly); Response.Redirect(Request.RawUrl); }
protected void Page_Load(object sender, EventArgs e) { //string url = "Sapo Cinema"; string url = DropDownList1.SelectedValue; if (url.Length == 0) { url = "http://feeds.feedburner.com/PublicoRSS"; } XmlDocument xdoc = XmlDataSource1.GetXmlDocument(); XmlNodeList elemList = xdoc.GetElementsByTagName("feed"); for (int i = 0; i < elemList.Count; i++) { System.Diagnostics.Debug.WriteLine(elemList[i].Attributes["name"].Value + "_feed.xml"); System.Diagnostics.Debug.WriteLine(DropDownList1.SelectedValue); if (elemList[i].Attributes["name"].Value == DropDownList1.SelectedValue) { string attrVal = elemList[i].Attributes["url"].Value; XmlReader reader = XmlReader.Create(attrVal); XmlDocument doc = new XmlDocument(); doc.Load(reader); reader.Close(); //doc.Save("C:/Users/Utilizador/Desktop/Universidade/4_ano/1_semestre/EDC/Práticas/EDC_ProjetoFinal/EDC_ProjetoFinal/EDC_ProjetoFinal/xml" + elemList[i].Attributes["name"].Value + "_feed.xml"); doc.Save("C:/Users/Utilizador/Desktop/Universidade/4_ano/1_semestre/EDC/Práticas/tp3/tp3/tp3/tp3/" + elemList[i].Attributes["name"].Value + "_feed.xml"); XmlDataSource4.DataFile = "~/" + elemList[i].Attributes["name"].Value + "_feed.xml"; } } XmlDocument xdoc1 = XmlDataSource4.GetXmlDocument(); elemList = xdoc1.GetElementsByTagName("url"); if (elemList.Count > 0) { XmlNode x1 = elemList[0].ChildNodes.Item(0); Image1.ImageUrl = x1.InnerText; } else { Image1.ImageUrl = null; } }