输入…注意注释是从XSD工具生成的代码。它在31834行文件中,并且是专有的,但我在这里给出了一个粗略的近似值。
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public class comment
{
private System.DateTime commentDateField;
private bool commentDateFieldSpecified;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public System.DateTime commentDate
{
get
{
return this.commentDateField;
}
set
{
this.commentDateField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool commentDateSpecified
{
get
{
return this.commentDateFieldSpecified;
}
set
{
this.commentDateFieldSpecified = value;
}
}
//other fields omitted for clarity
}
comment c = new comment();
c.text = txtComment.Text;
c.commentDate = DateTime.Now;
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
XmlSerializer xs = new XmlSerializer(typeof(comment));
xs.serialize(sw as TextWriter, c);
string output = sb.ToString();
输出-gt;
<comment>
<text>My Comment Text</text>
</comment>
日期在哪里?