Click here to Skip to main content
15,886,782 members
Articles / Programming Languages / XML

.NET XML and SOAP Serialization Samples, Tips

Rate me:
Please Sign up or sign in to vote.
4.82/5 (42 votes)
22 Jul 200510 min read 268K   4.7K   110  
Provides samples for XML and SOAP serialization using C#
using System;
using System.Collections;
using System.Xml.Serialization;
namespace SerializationSamples
{
	
	public class Exam{
		public Exam(){
			header=new Header();
			questions=new ArrayList();
		}
		private Header header;
		
		private ArrayList questions;
		public Header Header{
			get{return header;}
			set{header=value;}
		}
		[XmlArrayItem(typeof(Question))]
		public ArrayList Questions{
			get{return questions ;}
			set{questions=value;}
		}
	}

	public class Header{
		public Header(){}
		private string title;
		private string description;
		public string Title{
			get{return title;}
			set{title=value;}
		}
		public string Description{
			get{return description;}
			set{description=value;}
		}		
	}

	public class Question{
		public Question(){}
		private int id;
		private string title;
		private string[] items;
		public int ID{
			get{return id;}
			set{id=value;}
		}
		[System.Xml.Serialization.XmlElementAttribute("QuestionTitle")]	
		public string Title{
			get{return title;}
			set{title=value;}
		}
		[System.Xml.Serialization.XmlElementAttribute("Item")]			
		public string[] Items{
			get{return items;}
			set{items=value;}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
United Kingdom United Kingdom

Comments and Discussions