I have a XML like this:
<Data>
<Author>
<AuthorID>1</AuthorID>
<Name>Max</Name>
</Author>
<Author>
<AuthorID>2</AuthorID>
<Name>Steve</Name>
</Author>
<Book>
<AuthorID>1</AuthorID>
<Name>Book name</Name>
</Book>
<Book>
<AuthorID>2</AuthorID>
<Name>Book name 2</Name>
</Book>
When i use the "insert xml as class" function from visual studio i get classes like this:
public class Data() {
private DataAuthor[] dataAuthorFields;
private DataBook[] dataBookFields;
}
public class DataAuthor() {
private string AuthorID;
private string Name;
}
I have now two lists and can easy show all authors and all books. But additional i want to have a data model where i can get all books from one author:
public class DataAuthor() {
private string AuthorID;
private string Name;
**private DataBook[] Books;**
}
I can't change XML-File and just need one reference to all books from one auther. How i can do this properly?
Try using Linq