2
下面列出的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;
}
}
}
我不知道完整的答案,但我认为它将实现'标准化'上的'ToString'来返回'testField',然后使用一些属性来说'Standardize'只是一个字符串。 – 2012-07-25 21:19:23