We can do XML serialization using the LiquidXML classes. (another xml serializer: http://www.codeplex.com/Xsd2Code)
Actually, LiquidXML.XmlObject base from which everythign is derived has the iXMLserializable interface implemented.
For each returned object, the developers need to implement a proxy class that implements the
iXmlSerialier
Basically,
Article:
Customizing XML Serialization in .NET 2.0 Using the IXmlSerializable InterfaceBlog Entires:
http://www.hanselman.com/blog/CategoryView.aspx?category=XmlSerializer&page=1Look at Link to XSD:
Start of Class
[XmlSchemaProvider("MySchema")]
public class SongStream : IXmlSerializable
{
GenSchema
Public Function GetSchema() As _
System.Xml.Schema.XmlSchema _
Implements IXmlSerializable.GetSchema
Throw New System.NotImplementedException()
End Function
XXmlSchemaProvider
public static XmlQualifiedName MySchema(XmlSchemaSet xs)
{
// This method is called by the framework to get the schema for this type.
// We return an existing schema from disk.
XmlSerializer schemaSerializer = new XmlSerializer(typeof(XmlSchema));
string xsdPath = null;
// NOTE: replace the string with your own path.
xsdPath = System.Web.HttpContext.Current.Server.MapPath("SongStream.xsd");
XmlSchema s = (XmlSchema)schemaSerializer.Deserialize(
new XmlTextReader(xsdPath), null);
xs.XmlResolver = new XmlUrlResolver();
xs.Add(s);
return new XmlQualifiedName("songStream", ns);
}
[XmlSchemaProvider("MethodToGetSchema")]
WriteXML
Public Sub WriteXml(ByVal writer As XmlWriter) _
Implements IXmlSerializable.WriteXml
writer.WriteStartElement _
("employee", "urn:devx-com")
writer.WriteAttributeString _
("firstName", _firstName)
writer.WriteAttributeString _
("lastName", _lastName)
writer.WriteAttributeString _
("address", _address)
writer.WriteEndElement()
End Sub
ReadXML
void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
{
throw new System.NotImplementedException();
}