c# - How to load XML items to List of items -
i'd need load items xml list<t>
.could please give me advice how in c# class? have list<item> litems = new list<item>();
, xml file looks this:
<items> <item> <id>1</id> <title>aaa</title>> <imageurl>"images/aaa.gif"</imageurl> </item> <item> <id>2</id> <title>bbb</title> <imageurl>"images/bbb.jpg"</imageurl> </item> <item> <id>3</id> <title>ccc</title> <imageurl>"images/ccc.jpg"</imageurl> </item> </items>
var items = xdocument.load(filename) .descendants("item") .select(i => new item { id = (int)i.element("id"), title = (string)i.element("title"), imageurl = (string)i.element("imageurl"), }) .tolist();
Comments
Post a Comment