下面列出的C#类产生了这个XML:
<Standardize><TestString>Some Data</TestString></Standardize>
但是,我想要的是:
<Standardize>Some Data</Standardize>
换句话说,我希望TestString属性的内容显示在XML中,但我不希望将TestString属性列为元素。我可以添加一些属性来实现这一目标吗?
/// <Serialized C# Class/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://test.com/Services/1")]
public partial class Standardize {
private string testField;
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.None, IsNullable=true, ElementName=null)]
public string TestString {
get {
return testField;
}
set {
testField;= value;
}
}
}