i'm having a ListView
control like
I need to store the data from this ListView to an Xml File.
So the xml file will be like
<root>
<Child Name ="A1" val1="1" val2="0"/>
<Child Name ="A2" val1="1" val2="2"/>
<Child Name ="A3" val1="1" val2="3"/>
<Child Name ="A4" val1="1" val2="4"/>
<Child Name ="A5" val1="1" val2="5"/>
<Child Name ="A6" val1="6" val2="0"/>
<Child Name ="A7" val1="7" val2="0"/>
</root>
if the data is stored in some List
or Dictionary
, then i know to do this using XML to LINQ
But how do i do this from a ListView
XDocument XD=new XDocument(new XElement("root",........// what i have to do here.......
Please help me to do this...
Thanks in advance
You can query the list view subitems along with its column headers:
EDIT: Since neither ListViewItemCollection nor ListViewSubItemCollection support query operators out of the box, we need to call
Cast<T>()
to be able to use them.Here is a simple example. The goal here is to do it using XmlTextWriter. Of course, this sample needs to be modified to suit your particular file I/O and XML-formatting needs: