public class Book : IXmlSerializable
{
public Header Header { get; set; }
public Title Title { get; set; }
public XmlSchema GetSchema() => null;
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
int index = 1; // Start index counting
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Header")
{
Header = new Header { Index = index++ };
Header.ReadXml(reader);
}
else if (reader.NodeType == XmlNodeType.Element && reader.Name == "Title")
{
Title = new Title { Index = index++ };
Title.ReadXml(reader);
}
}
}
public void WriteXml(XmlWriter writer)
{
// Implement serialization logic if needed
}
}
public class Header : BaseElement, IXmlSerializable
{
public string Text { get; set; }
public void ReadXml(XmlReader reader)
{
reader.ReadStartElement("Header");
Text = reader.ReadElementContentAsString("Text", "");
reader.ReadEndElement();
}
public void WriteXml(XmlWriter writer)
{
// Implement serialization logic if needed
}
}