Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Create following classes to hold your data and validate it:</p> <pre><code>public class Community { public string Author { get; set; } public int CommunityId { get; set; } public string Name { get; set; } [XmlArray] [XmlArrayItem(typeof(RegisteredAddress))] [XmlArrayItem(typeof(TradingAddress))] public List&lt;Address&gt; Addresses { get; set; } } public class Address { private string _postCode; public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } public string AddressLine3 { get; set; } public string City { get; set; } public string Country { get; set; } public string PostCode { get { return _postCode; } set { // validate post code e.g. with RegEx _postCode = value; } } } public class RegisteredAddress : Address { } public class TradingAddress : Address { } </code></pre> <p>And serialize that instance of community class to xml:</p> <pre><code>Community community = new Community { Author = "xxx xxx", CommunityId = 0, Name = "name of community", Addresses = new List&lt;Address&gt; { new RegisteredAddress { AddressLine1 = "xxx", AddressLine2 = "xxx", AddressLine3 = "xxx", City = "xx", Country = "xxxx", PostCode = "0000-00" }, new TradingAddress { AddressLine1 = "zz", AddressLine2 = "xxx" } } }; XmlSerializer serializer = new XmlSerializer(typeof(Community)); serializer.Serialize(File.Create("file.xml"), community); </code></pre> <p>I think a little googling will help you to understand how to deserialize community object back from file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload