Introduction
The following code sample shows how to use XML serialization attributes such as SoapElement and SoapAttribute to generate custom SOAP format in the resulting XML during sterilization. The code defines a class named Institute and applies and XML serialization attributes to its members to format the resulting XML while serializing an object of the Institute class.
Code
public
class Institute
{
//Soap Custom Attribute Declaration
[SoapAttribute(AttributeName="Institute")]
public string
Name;
[SoapElement(ElementName =
"CorporateInstitute")]
public string
CorporateInstitute;
[SoapIgnore]
public string
InstituteID;
public override
string ToString()
{
//return base.ToString();
string send;
send="\nInstitute Name:"+this.Name;
send+="\nCorporate Institute:"+this.CorporateInstitute;
send+="\nInstitueID :"+this.InstituteID;
return send;
}
static void
Main(string[] args)
{
//Specify xml file
path
Join the conversation! Your thoughts help the community grow.