title: 'There is an error in XML document (30, 10)' error while returning difference type from XML element type
body: <p>I have a XML file. I want map it to an object. one of xml elements is string and I want to convert this string to int value of an Enum in set section of property. then return this int value, but when file reader want to deserialize my XML file to object, I get runtime error which says "There is an error in XML document (30, 10)".</p>
  
  <pre><code>private int processCodeInt;
      [XmlElement("ProcessCode")]
      public int ProcessCode
      {
          get { return this.processCodeInt; }
          set
          {
              var temp = typeof(Common.Transaction.Definition_Transaction.Def_TrxType_Detail)
                  .GetMembers().Where(i =&gt; i.MemberType == MemberTypes.Field).ToList();
              this.processCodeInt = Convert.ToInt32(temp.Where(u =&gt; u.Name == value.ToString()).FirstOrDefault().ToString());
          }
      }
  </code></pre>
  
  <p>Thank you all.</p>
  
  <p>in follow I leave my codes:</p>
  
  <p>Mapping classes:</p>
  
  <pre><code>[XmlRoot("Model")]
      public class Model
      {
          [XmlElement("Transaction")]
          public List&lt;Transaction&gt; Transactions;
      }
      public class Transaction
      {
          [XmlElement("Message")]
          public List&lt;Message&gt; Messages;
      }
      public class Message
      {
          [XmlElement("In")]
          public MessageType In { get; set; }
          [XmlElement("Out")]
          public MessageType Out { get; set; }
      }
      public class MessageType
      {
          [XmlElement("ChannelType")]
          public int ChannelType { get; set; }
          [XmlElement("TransactionType")]
          public int TransactionType { get; set; }
          private int processCodeInt;
          [XmlElement("ProcessCode")]
          public int ProcessCode
          {
              get { return this.processCodeInt; }
              set
              {
                  var temp = typeof(Common.Transaction.Definition_Transaction.Def_TrxType_Detail)
                      .GetMembers().Where(i =&gt; i.MemberType == MemberTypes.Field).ToList();
                  temp.RemoveAt(0);
                  MemberInfo[] processCodeMemberInfos = temp.ToArray();
                  this.processCodeInt = Convert.ToInt32(processCodeMemberInfos.Where(u =&gt; u.Name == value.ToString()).FirstOrDefault().ToString());
  
              }
          }
          [XmlElement("IsExpired")]
          public bool IsExpired { get; set; }
      }
  </code></pre>
  
  <p>my XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Model&gt;
    &lt;Transaction&gt;
      &lt;Message&gt;
        &lt;In&gt;
          &lt;ChannelType&gt;0&lt;/ChannelType&gt;
          &lt;TransactionType&gt;1&lt;/TransactionType&gt;
          &lt;ProcessCode&gt;Balance&lt;/ProcessCode&gt;
          &lt;IsExpired&gt;0&lt;/IsExpired&gt;
        &lt;/In&gt;
        &lt;Out&gt;
          &lt;ChannelType&gt;1&lt;/ChannelType&gt;
          &lt;TransactionType&gt;1&lt;/TransactionType&gt;
          &lt;ProcessCode&gt;Balance&lt;/ProcessCode&gt;
          &lt;IsExpired&gt;0&lt;/IsExpired&gt;
        &lt;/Out&gt;
      &lt;/Message&gt;
    &lt;/Transaction&gt;
  &lt;/Model&gt;
  </code></pre>
  
  <p>Mapping Code:</p>
  
  <pre><code>var TransactionModelsFile = new System.IO.StreamReader(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
              +@"/TransactionModels.xml");
              System.Xml.Serialization.XmlSerializer reader =
              new System.Xml.Serialization.XmlSerializer(typeof(Model));
              overview = (Model)reader.Deserialize(TransactionModelsFile);
              TransactionModelsFile.Close();
  </code></pre>