Xml Attributes....  
Author Message
Ralph Krausse





PostPosted: ASMX Web Services and XML Serialization, Xml Attributes.... Top

I have a class that I wish to serialize to a string using XmlSerializer. My class...

[Serializable]
public class CApplication
{
private int m_application_id;
public int application_id
{
get { return m_application_id; }
set { m_application_id = value; }
}
}


The string returned looks like

< xml version="1.0" >
<CApplication xmlns:xsi=" http://www.hide-link.com/ " xmlns:xsd=" http://www.hide-link.com/ ">
<application_id>0</application_id>
</CApplication>


I need it look like this....

< xml version="1.0" >
<CApplication xmlns:xsi=" http://www.hide-link.com/ " xmlns:xsd=" http://www.hide-link.com/ ">
<application_id Type="Int32">0</application_id>
</CApplication>


I need to add the 'Type="Int32"' part of some attribute so that I know it is a integer. I am having
MAJOR problems. I have more public members, datetimes, string, bools, etc and I wish to have each
element in the string describe the datatype .....


anyone thanks



.NET Development29  
 
 
SaravanaKumar_1977





PostPosted: ASMX Web Services and XML Serialization, Xml Attributes.... Top

Please find the serializable class below. You have to do custom serialization in the get property of the serializable class (which I haven't written). The logic that you have to implement is you have to get the type name of the variable and assign for the xmlattribute.