X
xlar54
Lets say I have an xml document that reads:
<Book>
<ID>
<Title>SomeTitle</Title>
<ISBN>12345</ISBN>
</ID>
</Book>
But I want to deserialize it to an object that looks like:
[XmlRoot("Book")]
public class Book
{
[XmlElement(ElementName="Title")]
public string Title;
[XmlElement(ElementName="ISBN"])
public string isbn;
}
The problem appears to be the ID element in the xml document. How do
I qualify the XmlElement attributes so that the Title goes into the
Title, and ISBN goes into ISBN? Should it be something like
[XmlElement(ElementName="ID.Title")] ?
<Book>
<ID>
<Title>SomeTitle</Title>
<ISBN>12345</ISBN>
</ID>
</Book>
But I want to deserialize it to an object that looks like:
[XmlRoot("Book")]
public class Book
{
[XmlElement(ElementName="Title")]
public string Title;
[XmlElement(ElementName="ISBN"])
public string isbn;
}
The problem appears to be the ID element in the xml document. How do
I qualify the XmlElement attributes so that the Title goes into the
Title, and ISBN goes into ISBN? Should it be something like
[XmlElement(ElementName="ID.Title")] ?