下面列出的C#类生成此XML:
<Standardize><TestString>Some Data</TestString></Standardize>
Run Code Online (Sandbox Code Playgroud)
但是,我想要的是:
<Standardize>Some Data</Standardize>
Run Code Online (Sandbox Code Playgroud)
换句话说,我希望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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
412 次 |
| 最近记录: |