I have a .dtd file which has been converted to a .xsd file. This file has an element Identity:
<xs:element name="Identity">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" />
</xs:sequence>
<xs:attribute name="lastChangedTimestamp" type="xs:string" />
</xs:complexType>
</xs:element>
This generates the following sample xml, with some text content:
<Identity lastChangedTimestamp="lastChangedTimestamp1" xmlns="http://tempuri.org/cXML">text</Identity>
I converted the .xsd to a .cs file using xsd.exe:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://tempuri.org/cXML")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://tempuri.org/cXML", IsNullable = false)]
public partial class Identity
{
public string Text { get; set; }
private System.Xml.XmlNode[] anyField;
private string lastChangedTimestampField;
/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
[System.Xml.Serialization.XmlAnyElementAttribute()]
public System.Xml.XmlNode[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string lastChangedTimestamp
{
get
{
return this.lastChangedTimestampField;
}
set
{
this.lastChangedTimestampField = value;
}
}
}
However this does not allow me to set the text content of the identity node:
var credential = new Credential()
{
Identity = new Identity()
{
lastChangedTimestamp = "lastChangedTimestamp1",
//Text = "MyRef" <- would like to set it at this point
}
};
Is there anything I can do to ensure that when I serialize the Identity object I can get my ref into the text content of the node, or is this not supported?
<Identity lastChangedTimestamp="lastChangedTimestamp1">
MyRef
</Identity>