title: The ReadElementContentAsString method is not supported on node type EndElement
body: <p>I am trying to read xml file with XmlTextReader class my xml file is </p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8' standalone='yes'?&gt;
  &lt;AppXmlLogWritter&gt;
  &lt;LogData&gt;&lt;LogID&gt;999992013021213232800001&lt;/LogID&gt;&lt;LogDateTime&gt;20130212132328&lt;/LogDateTime&gt;&lt;LogType&gt;Message&lt;/LogType&gt;&lt;LogFlag&gt;Flag&lt;/LogFlag&gt;&lt;LogApplication&gt;Application&lt;/LogApplication&gt;&lt;LogModule&gt;Module&lt;/LogModule&gt;&lt;LogLocation&gt;Location&lt;/LogLocation&gt;&lt;LogText&gt;Text&lt;/LogText&gt;&lt;LogStackTrace&gt;Stacktrace&lt;/LogStackTrace&gt;&lt;/LogData&gt;
  &lt;/AppXmlLogWritter&gt;
  </code></pre>
  
  <p>with the following code</p>
  
  <pre><code>FileStream fileStream = File.Open(txtBrowseFilePath.Text, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
               using (XmlTextReader objXmlReader = new XmlTextReader(fileStream))
  {
                  IEnumerable&lt;LogData&gt; data = LogData.GetLogData(objXmlReader);
  
                  using(var item = data.GetEnumerator())
                  {
                      while (item.MoveNext())
                      {
                          DataRow dataRow;
                          dataRow = dataTable.NewRow();
  
                          dataRow[0] = item.Current.LogID;
                          dataRow[1] = item.Current.LogDateTime;
                          dataRow[2] = item.Current.LogType;
                          dataRow[3] = item.Current.LogFlag;
                          dataRow[4] = item.Current.LogApplication;
                          dataRow[5] = item.Current.LogModule;
                          dataRow[6] = item.Current.LogLocation;
                          dataRow[7] = item.Current.LogText;
                          dataRow[8] = item.Current.LogStackTrace;
  
                          dataTable.Rows.Add(dataRow);
                      }
                  }}
  public static IEnumerable&lt;LogData&gt; GetLogData(XmlTextReader objXmlReader)
          {
              LogData objLogData = null;
              IXmlLineInfo xmlInfo = (IXmlLineInfo)objXmlReader;
              while(objXmlReader.Read())
              {
  
  
                  if(objXmlReader.IsStartElement("LogData"))
                  {
                      objLogData = new LogData();
                  }
                  if(objXmlReader.Name == "LogData" &amp;&amp; objXmlReader.NodeType == XmlNodeType.EndElement)
                  {
                      yield return objLogData;
                  }
                  if(objXmlReader.Name == "LogID")
                  {
                      objLogData.LogID = objXmlReader.ReadElementContentAsString();
                  }
                  else if (objXmlReader.Name == "LogDateTime")
                  {          
                      objLogData.LogDateTime = objXmlReader.ReadElementContentAsString();                   
                  }
                  else if(objXmlReader.Name == "LogType")
                  {
                      objLogData.LogType = objXmlReader.ReadElementContentAsString();
                  }
                  else if(objXmlReader.Name == "LogFlag")
                  {
                      objLogData.LogFlag = objXmlReader.ReadElementContentAsString();
                  }
                  else if(objXmlReader.Name == "LogApplication")
                  {
                      objLogData.LogApplication = objXmlReader.ReadElementContentAsString();
                  }
                  else if(objXmlReader.Name == "LogModule")
                  {
                      objLogData.LogModule = objXmlReader.ReadElementContentAsString();
                  }
                  else if(objXmlReader.Name == "LogLocation")
                  {
                      objLogData.LogLocation = objXmlReader.ReadElementContentAsString();
                  }
                  else if(objXmlReader.Name == "LogText")
                  {
                      objLogData.LogText = objXmlReader.ReadElementContentAsString();
                  }
                  else if(objXmlReader.Name == "LogStackTrace")
                  {
                      objLogData.LogStackTrace = objXmlReader.ReadElementContentAsString();
                  }
              }
          }
  </code></pre>
  
  <p>but it give me an error <strong>"The ReadElementContentAsString method is not supported on node type EndElement "</strong>
  but when my xml file is as</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;AppXmlLogWritter&gt;
  &lt;LogData&gt;
  &lt;LogID&gt;999992013021110381000001&lt;/LogID&gt;
  &lt;LogDateTime&gt;20130211103810&lt;/LogDateTime&gt;
  &lt;LogType&gt;Message&lt;/LogType&gt;
  &lt;LogFlag&gt;Flag&lt;/LogFlag&gt;
  &lt;LogApplication&gt;Application&lt;/LogApplication&gt;
  &lt;LogModule&gt;Module&lt;/LogModule&gt;
  &lt;LogLocation&gt;Location&lt;/LogLocation&gt;
  &lt;LogText&gt;Text&lt;/LogText&gt;
  &lt;LogStackTrace&gt;Stacktrace&lt;/LogStackTrace&gt;
  &lt;/LogData&gt;
  &lt;/AppXmlLogWritter&gt;
  </code></pre>
  
  <p>its work fine but i didnt get yet what actual problem with abouve xml file why it give me an error as i menstion. error occured at this line</p>
  
  <pre><code> objLogData.LogDateTime = objXmlReader.ReadElementContentAsString();  
  </code></pre>
  
  <p>Thnkx for ur reply</p>