Is there a way to convert an object to XML but each element contains an attribute (let's be like this xt:type="int").
I know I can do it manually using reflection and iterate properties and ....
I'm asking if there's a way to generate it using pre-made library or something.
What I'm doing now is:
XmlDocument doc = new XmlDocument();
XmlSerializer ser = new XmlSerializer(document.GetType());
string result = string.Empty;
using (MemoryStream memStm = new MemoryStream())
{
ser.Serialize(memStm, document);
memStm.Position = 0;
result = new StreamReader(memStm).ReadToEnd();
}
Because later I need to read it back to an object. All this I want to do it programmatically, not using XSD tool.
Thanks
UPDATE 1:
What I want to get looks something like this:
<note>
<propertyName1 xs:type="string">value1</to>
<propertyName2 xs:type="int">10</to>
<propertyName2 xs:type="datetime">04-06-2015 01:10:00</to>
</note>
The most important is the attribute xs:type.