日期:2014-05-18  浏览次数:20690 次

关于对象序列化的一个问题,急..
有一个对象
  [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://marketing.ews.yahooapis.com/V4")]
  public partial class TargetingAttribute {
   
  private TargetingAttributeDescriptor[] targetsField;
   
  /// <remarks/>
  [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)]
  public TargetingAttributeDescriptor[] targets {
  get {
  return this.targetsField;
  }
  set {
  this.targetsField = value;
  }
  }
  }

  子对象
  [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://marketing.ews.yahooapis.com/V4")]
  public partial class TargetingAttributeDescriptor {
   
  private long idField;
   
  private bool idFieldSpecified;
   
  private System.Nullable<TargetingAttributeType> typeField;
   
  private bool typeFieldSpecified;
   
  /// <remarks/>
  public long ID {
  get {
  return this.idField;
  }
  set {
  this.idField = value;
  }
  }
   
  /// <remarks/>
  [System.Xml.Serialization.XmlIgnoreAttribute()]
  public bool IDSpecified {
  get {
  return this.idFieldSpecified;
  }
  set {
  this.idFieldSpecified = value;
  }
  }
   
  /// <remarks/>
  [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
  public System.Nullable<TargetingAttributeType> type {
  get {
  return this.typeField;
  }
  set {
  this.typeField = value;
  }
  }
   
  /// <remarks/>
  [System.Xml.Serialization.XmlIgnoreAttribute()]
  public bool typeSpecified {
  get {
  return this.typeFieldSpecified;
  }
  set {
  this.typeFieldSpecified = value;
  }
  }
  }

我将TargetingAttribute 进行xml序列化后,得到的结果是
<?xml version="1.0" encoding="utf-16"?>
<TargetingAttribute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <targets xmlns="http://marketing.ews.yahooapis.com/V4">
  <TargetingAttributeDescriptor />
&nb