Это тестовый xml, который я использую:
<categories>
<category id="1" name="Test1">
<category id="2" name="Test2">
<misc id="1"></misc>
</category>
</category>
<category id="3" name="Test3">
<misc id="2"></misc>
</category>
Now i want to bind that to an ASPX treeview, i want only the elements that have the name category and i want the name of those to appear in the treeview.
Легко получить идентификатор и имена:
var d = from t in data.Descendants("category")
select new { ID = t.Attribute("id").Value, Name = t.Attribute("name").Value };
но как мне сохранить структуру в дереве?
Это должно выглядеть так:
Тест1
-> Тест2
Тест3