.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.IO;
using System.Collections.Generic;
using System.Xml.Serialization;
					
public class Program
{
	public static void Main()
	{
		var serializer = new XmlSerializer(typeof(Carpark));
		using var sr = new StringReader(xml);
		var cp = (Carpark)serializer.Deserialize(sr);
		cp.Dump();
	}
	
	static string xml = @"
	<Carpark>
   <Trucks>
      <Truck brand='Chrysler' kg='2100'/>
   </Trucks>
   <Cars>
      <Car brand='Mercedes' kg='1100'/>
   </Cars>
   <Tractors>
      <Tractor brand='John Deere' kg='1500'/>
   </Tractors>
</Carpark>";

	public class Carpark
	{
		public List<Truck> Trucks { get; set; }
		public List<Car> Cars { get; set; }
		public List<Tractor> Tractors { get; set; }
	}

	[XmlInclude(typeof(Truck))]
	[XmlInclude(typeof(Car))]
	[XmlInclude(typeof(Tractor))]
	public class Vehicle
	{
		[XmlIgnore]
		public string Type => this.GetType().Name;
		
		[XmlAttribute("brand")]
		public string Brand { get; set; }
		
		[XmlAttribute("kg")]
		public int Weight { get; set; }
	}
	
	public class Truck : Vehicle
	{
	}
	
	public class Car : Vehicle
	{
	}
	
	public class Tractor : Vehicle
	{
	}
}
;