Hey have a little problem, I'm having a xml-file structured like this:
<cars>
<car name="audi" id="123">
<specs fuel="gas"/>
<specs horsepower="150"/>
</car>
<car name="tesla" id="456">
<specs fuel="electric"/>
<specs horsepower="600"/>
</car>
</cars
I am trying to read all the data and maintain the treestructure from the xml in the code so that I can display the car that I want lateron. Therefore I used an ObservableCollection. I tried it like this:
XElement data = XElement.Load(path);
IEnumerable<XElement> elements = data.Elements().Elements();
XmlData = new ObservableCollection<XElement>();
foreach(var item in elements)
{
XmlData.Add(item);
}
With this method it doesn't add them in the collection. How can I get the different nodes from the loaded XElements and store them in an ObservableCollection? Or is there a much easier way to do this? Thanks already :)