Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have list listbox named=Favorites
also created and XML file named Favorites.xml

XML
<?xml version="1.0" encoding="utf-8"?>
<XMLFILE>
  <Title>Favorites</Title>
  <Items>http://uk.yahoo.com/</Items>
  <Items>http://www.google.co.in/</Items>
</XMLFILE>



i am able to delete the item listbox ..the problem is removing deleted item from XML file too
Posted
Comments
Jameel VM 24-Jun-13 4:19am    
can you post the code you have tried?
Siddharth Koya 24-Jun-13 4:45am    
@ Jameel: Here is the code it is giving me an Exception

XElement root = XElement.Load(@"D:\Projects Related\WebBrowser1\WebBrowser1\bin\Debug\Favorites.xml");
if (e.KeyCode == Keys.Delete)
{
foreach (Object index in Favorites.SelectedIndices)
{
root.Elements("Entry").ElementAt((int)index).Remove();
Favorites.Items.RemoveAt((int)index);
}
root.Save(@"D:\Projects Related\WebBrowser1\WebBrowser1\bin\Debug\Favorites.xml");

1 solution

@Jameel i solved it .. i should have put root.Elements("Items").ElementAt((int)index).Remove();

Thank u anyway :)
 
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