I'm trying to read two Aux files with one class, but I'm having trouble.
I'm getting an error when I try to serialize my class. The xml schema is defined by a third-party and I can't change it.
The xml looks like this
<General>
<Projection>
<Type>AA-A</Type>
<Parameter>A12</Parameter>
</Projection>
</General>
And another xml file
<General>
<Projection>AA-A</Projection>
</General>
The class I defined is this
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class General
{
private GeneralProjection projectionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public GeneralProjection Projection
{
get
{
return this.projectionField;
}
set
{
this.projectionField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class GeneralProjection
{
private string typeField;
private string parameterField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Parameter
{
get
{
return this.parameterField;
}
set
{
this.parameterField = value;
}
}
}
The first xml file reads well, but the second file cannot.
Please help.
I've tried the following methods, An error has occurred: "The XML element 'Projection' of 'Namespace' already exists in the current range."
// GeneralProjection 타입의 Projection 처리
[System.Xml.Serialization.XmlElementAttribute("Projection", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public GeneralProjection GeneralProjection
{
get { return this.projectionField; }
set { this.projectionField = value; }
}
// string 타입의 Projection 처리
[System.Xml.Serialization.XmlElementAttribute("Projection", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ProjectionString
{
get { return this.projectionStringField; }
set { this.projectionStringField = value; }
}