I have two objects – Book and Shelf.
class Book
{
}
class Shelf
{
}
As you can see, they are not inner.
How to serialize them, so that I get xml that looks like this:
<Book bookAttribute="">
<Shelf>bla</Shelf>
<Shelf>bla1</Shelf>
</Book>
I’m going to take a crack at it here and assume that with the info you’ve given you need a class structure like this:
Then when you create the programmatic relationship between a book and shelves (which seems backward to me – but I don’t know what the whole scenario is) you can then loop it during your “Save” routine to write it as XML.
In the event that the original structures cannot be modified, you can still derive classes from them:
…unless the class is sealed in which case you’ll have to create ugly arrays of arrays.