Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an xml file.

XML
<?xml version="1.0" encoding="utf-8" ?>
<Vehicle>
   <feature id = "1" name = "car">
     <propery id = "1" name = "Model Number"/>
     <property id = "2" name = "Color of car"/>
   </feature>
   <feature id = "2" name = "Bike">
      <property id = "1" name = "Model of bike"/>
      <property id ="2" name = "Compnay name"/>
   </feature>
</vehicle>



in this element is feature i want to read the name attribute of all features.

update into object of observable collection.

And this observable collection bind with Listview control of wpf.

Thanks
Posted
Comments
johannesnestler 3-Dec-13 9:46am    
sounds trivial, what's your problem? read attributes? create a corresponding model? binding?
bunty swapnil 3-Dec-13 23:17pm    
all i am new to xml and mvvm model.
johannesnestler 4-Dec-13 4:37am    
Ok I see, so you have a Vehicle - this is your model. Implement reading of XML through your model then on your ViewModel you will have the observable collection holding the vehicle's of your model. Then you bind this observable collection to the ListView (implement a DataTemplate for the ListViewItems corresponding to vehicle in your view). For reading the XML I'd prefer LinqToXML (XDocument, XElement - have a look at the System.Xml.Linq Namespace). Maybe you try it for yourself and come back here with more specific questions...

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