i want to serialize the following class as child of another class.
[XmlInclude(typeof(string)), XmlInclude(typeof(XML_Variable))]
public class XMLTagDataSection
{
[XmlElement("Offset")]
public int XML_Offset { get; set; }
[XmlElement("Type")]
public EnuDataType XML_type { get; set; }
[XmlElement("Value")]
public object XML_Value { get; set; }
[XmlElement("Info")]
public string XML_Info { get; set; }
[XmlElement("NumBytes")]
public int XML_NumBytes { get; set; }
}
public class XML_Variable
{
[XmlElement("Variable", IsNullable = false)]
public int Variable { get; set; }
}
this is my actual output:
<Data>
<Offset>0</Offset>
<Type>ASCII</Type>
<Value xmlns:q1="http://www.w3.org/2001/XMLSchema" d7p1:type>test-string</Value>
<Info>some text</Info>
<NumBytes>11</NumBytes>
</Data>
<Data>
<Offset>11</Offset>
<Type>ASCII</Type>
<Value d7p1:type="XML_Variable" xmlns:d7p1="http://www.w3.org/2001/XMLSchema-instance">
<Variable>0</Variable>
</Value>
<Info>a variable</Info>
<NumBytes>5</NumBytes>
how can i get rid of the namespace of my XML_Value element? to get the following output:
<Data>
<Offset>0</Offset>
<Type>ASCII</Type>
<Value>test-string</Value>
<Info>some text</Info>
<NumBytes>11</NumBytes>
</Data>
<Data>
<Offset>11</Offset>
<Type>ASCII</Type>
<Value>
<Variable>0</Variable>
</Value>
<Info>a variable</Info>
<NumBytes>5</NumBytes>
i use this part of code to serialize the parent element:
XmlSerializerNamespaces NameSpace = new XmlSerializerNamespaces();
NameSpace.Add("", "");
XmlSerializer xmlserializer = new XmlSerializer(typeof(XMLRoot));
FileStream str = new FileStream(fileName, FileMode.Create);
xmlserializer.Serialize(str, Root_Tag, NameSpace);
str.Close();
return true;