title: Trying to deserialize a netcore csproj from XML to Object
body: <p>I'm trying to deserialise a xml doc into a poco class, obviously, the <code>csproj</code> files aren't the strictest XML files (missing <code>xml</code> header`), but they pass all the validation checks.</p>
  <p>The error I'm getting is <code>&lt;Project xmlns=''&gt; was not expected.</code>, and the code to deserialise is below.</p>
  <p>Have I missed something blindingly obvious?</p>
  <p><code>            var csProj = projPath.ParsePathToXML&lt;CsProj2.Models.Project&gt;(&quot;Project&quot;);</code></p>
  <pre><code>public static T ParsePathToXML&lt;T&gt;(this string @this, string root = &quot;&quot;)
      {
          string xml = File.ReadAllText(@this);
  
          XmlSerializer serializer = new XmlSerializer(typeof(T), root);
          T result;
  
          using (TextReader reader = new StringReader(xml))
          {
              result = (T)serializer.Deserialize(reader);
          }
  
          return result;
      }
  
  
  [XmlRoot(ElementName = &quot;PropertyGroup&quot;)]
  public class PropertyGroup
  {
      [XmlElement(ElementName = &quot;TargetFramework&quot;)]
      public string TargetFramework { get; set; }
      [XmlElement(ElementName = &quot;RuntimeIdentifier&quot;)]
      public string RuntimeIdentifier { get; set; }
      [XmlElement(ElementName = &quot;RuntimeFrameworkVersion&quot;)]
      public string RuntimeFrameworkVersion { get; set; }
      [XmlElement(ElementName = &quot;TargetsForTfmSpecificBuildOutput&quot;)]
      public string TargetsForTfmSpecificBuildOutput { get; set; }
      [XmlElement(ElementName = &quot;PreserveCompilationContext&quot;)]
      public string PreserveCompilationContext { get; set; }
      [XmlElement(ElementName = &quot;AssemblyName&quot;)]
      public string AssemblyName { get; set; }
      [XmlElement(ElementName = &quot;OutputType&quot;)]
      public string OutputType { get; set; }
      [XmlElement(ElementName = &quot;PackageId&quot;)]
      public string PackageId { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyTitleAttribute&quot;)]
      public string GenerateAssemblyTitleAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyDescriptionAttribute&quot;)]
      public string GenerateAssemblyDescriptionAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyConfigurationAttribute&quot;)]
      public string GenerateAssemblyConfigurationAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyCompanyAttribute&quot;)]
      public string GenerateAssemblyCompanyAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyProductAttribute&quot;)]
      public string GenerateAssemblyProductAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyCopyrightAttribute&quot;)]
      public string GenerateAssemblyCopyrightAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyVersionAttribute&quot;)]
      public string GenerateAssemblyVersionAttribute { get; set; }
      [XmlElement(ElementName = &quot;GenerateAssemblyFileVersionAttribute&quot;)]
      public string GenerateAssemblyFileVersionAttribute { get; set; }
      [XmlElement(ElementName = &quot;DocumentationFile&quot;)]
      public string DocumentationFile { get; set; }
      [XmlElement(ElementName = &quot;Authors&quot;)]
      public string Authors { get; set; }
      [XmlElement(ElementName = &quot;PublishWithAspNetCoreTargetManifest&quot;)]
      public string PublishWithAspNetCoreTargetManifest { get; set; }
      [XmlElement(ElementName = &quot;VersionPrefix&quot;)]
      public string VersionPrefix { get; set; }
      [XmlElement(ElementName = &quot;VersionSuffix&quot;)]
      public string VersionSuffix { get; set; }
      [XmlElement(ElementName = &quot;IsPackable&quot;)]
      public string IsPackable { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;Content&quot;)]
  public class Content
  {
      [XmlElement(ElementName = &quot;CopyToOutputDirectory&quot;)]
      public string CopyToOutputDirectory { get; set; }
      [XmlAttribute(AttributeName = &quot;Update&quot;)]
      public string Update { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;ItemGroup&quot;)]
  public class ItemGroup
  {
      [XmlElement(ElementName = &quot;Content&quot;)]
      public List&lt;Content&gt; Content { get; set; }
      [XmlElement(ElementName = &quot;PackageReference&quot;)]
      public List&lt;PackageReference&gt; PackageReference { get; set; }
      [XmlElement(ElementName = &quot;ProjectReference&quot;)]
      public ProjectReference ProjectReference { get; set; }
      [XmlElement(ElementName = &quot;BuildOutputInPackage&quot;)]
      public BuildOutputInPackage BuildOutputInPackage { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;PackageReference&quot;)]
  public class PackageReference
  {
      [XmlAttribute(AttributeName = &quot;Include&quot;)]
      public string Include { get; set; }
      [XmlAttribute(AttributeName = &quot;Version&quot;)]
      public string Version { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;ProjectReference&quot;)]
  public class ProjectReference
  {
      [XmlAttribute(AttributeName = &quot;Include&quot;)]
      public string Include { get; set; }
      [XmlAttribute(AttributeName = &quot;PrivateAssets&quot;)]
      public string PrivateAssets { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;BuildOutputInPackage&quot;)]
  public class BuildOutputInPackage
  {
      [XmlAttribute(AttributeName = &quot;Include&quot;)]
      public string Include { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;Target&quot;)]
  public class Target
  {
      [XmlElement(ElementName = &quot;ItemGroup&quot;)]
      public ItemGroup ItemGroup { get; set; }
      [XmlAttribute(AttributeName = &quot;Name&quot;)]
      public string Name { get; set; }
      [XmlAttribute(AttributeName = &quot;DependsOnTargets&quot;)]
      public string DependsOnTargets { get; set; }
  }
  
  [XmlRoot(ElementName = &quot;Project&quot;)]
  public class Project
  {
      [XmlElement(ElementName = &quot;PropertyGroup&quot;)]
      public List&lt;PropertyGroup&gt; PropertyGroup { get; set; }
      [XmlElement(ElementName = &quot;ItemGroup&quot;)]
      public List&lt;ItemGroup&gt; ItemGroup { get; set; }
      [XmlElement(ElementName = &quot;Target&quot;)]
      public Target Target { get; set; }
      [XmlAttribute(AttributeName = &quot;Sdk&quot;)]
      public string Sdk { get; set; }
  }
  </code></pre>