Create an in-memory XML document
Class Car Public PetName As String Public ID As Integer End Class Module Program Sub Main() '. Dim inventoryDoc As XDocument = _ New XDocument( _ New XDeclaration("1.0", "utf-8", "yes"), _ New XComment("Current Inventory of AutoLot"), _ New XElement("Inventory", _ New XElement("Car", New XAttribute("ID", "1"), _ New XElement("Color", "Green"), _ New XElement("Make", "BMW"), _ New XElement("PetName", "Stan") _ ), _ New XElement("Car", New XAttribute("ID", "2"), _ New XElement("Color", "Pink"), _ New XElement("Make", "Yugo"), _ New XElement("PetName", "A") _ ) _ ) _ ) Console.WriteLine(inventoryDoc) inventoryDoc.Save("SimpleInventory.xml") End Sub End Module