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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -