序列化一个字符串到CDATA元素(.NET 1.1)
2007-04-16 14:29 sun@live 阅读(630) 评论(1) 编辑 收藏 举报public class CDATA : IXmlSerializable
{
private string text;
public CDATA()
{}
public CDATA(string text)
{
this.text = text;
}
public string Text
{
get { return text; }
}
XmlSchema IXmlSerializable.GetSchema()
{
return null;
}
void IXmlSerializable.ReadXml(XmlReader reader)
{
this.text = reader.ReadString();
}
void IXmlSerializable.WriteXml(XmlWriter writer)
{
writer.WriteCData(this.text);
}
}
[Serializable]
public class ErrorMessage
{
private CDATA message;
….
[XmlElement("message", Type=typeof(CDATA))]
public CDATA Message
{
get { return message; }
set { message = value; }
}
….
}