title: Generate list of objects from XML stored in SqlXml variable
body: <p>I have <code>BIObject</code> class</p>
  
  <pre><code>public class BIObject
  {
      public string Database { get; set; }
      public string Schema { get; set; }
      public string Name { get; set; }
      public string ObjectType { get; set; }
  }
  </code></pre>
  
  <p>and also have below XML</p>
  
  <pre><code>&lt;root&gt;
    &lt;objects&gt;
      &lt;object database="LynxReporting" schema="dbo" name="rptusp_GLTDRSummary" type="P"/&gt;
      &lt;object database="IntraDay" schema="dbo" name="BMHGLCloseDetails" type="T"/&gt;
      &lt;object database="LynxReporting" schema="dbo" name="factGeneralLedger" type="P"/&gt;
    &lt;/objects&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I need to create <code>List&lt;IBObject&gt;</code> from the XML</p>
  
  <p><strong>Note: I load the XML from database into a property of type SqlXml</strong> so I need to convert SqlXml to <code>List&lt;IBObject&gt;</code></p>
  
  <p>Looked at couple of answers but could not figure out how I can do that.</p>
  
  <p>EDIT:</p>
  
  <p>I used below code </p>
  
  <pre><code>using (StringReader reader = new StringReader(myXmlString))
  {
      XmlSerializer serializer = new XmlSerializer(typeof(List&lt;BIObject&gt;));
      List&lt;BIObject&gt; objs = (List&lt;BIObject&gt;)serializer.Deserialize(reader);
  }
  </code></pre>
  
  <p>but got error </p>
  
  <blockquote>
    <p>There is an error in XML document (1, 2).</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>root xmlns='' was not expected.</p>
  </blockquote>