I have a listview which contains data in Details view mode. So now my task is to take back up of data which ever i select from listview and create .xml file.I created a button “Export” and put a code to open “SaveFileDialog” in export_Click event handler.Now can anybody provide me the logic to achieve the task to create .xml file from the datas selected from listview in "export_Click” eventhandler .
This is the bit of listview code used in the existing application.
public class TrevoListView : System.Windows.Forms.ListView, IEditable
public class BaseLVItem : System.Windows.Forms.ListViewItem
public TrevoListView ListView
{
get{ return t_listView; }
}
If i iterate by using foreach loop , i will get each object like shown below, but i really stuck what logic i can do for creating xml?
foreach(BaseLVItem item in ListView.SelectedItems)
And one more thing these all datas displayed in listivew are from parent xml files. Server will serialize these xml and send it to GUI for displaying in controls like listview, we also have dataschema “TrevoDataSchema.xsd”
Do i need to use XDocument or any other logic in side export_Click event handler ?
You could use XDocument from LINQ to XML and create a XML file from the ListItems, as shown in this answer https://stackoverflow.com/a/4067146/64497
And use
To save the xml file,
filenamehere is the name returned by theSaveFileDialog