I am trying to figure out what the best method is for writing an XML Document. Below is a simple example of what I am trying to create off of data I am pulling from our ERP syst
If you don't want (or can't) to use LINQ to XML, neither to duplicate your Order class to include XML serialization, and thinks XmlWriter is too much verbose, you can go with plain classical XmlDocument class:
// consider Order class that data structure you receive from your ERP system
List orders = YourERP.GetOrders();
XmlDocument xml = new XmlDocument();
xml.AppendChild(xml.CreateElement("Orders"));
foreach (Order order in orders)
{
XmlElement item = xml.CreateElement("Order");
item.SetAttribute("OrderNumber", order.OrderNumber);
item.AppendChild(xml.CreateElement("ItemNumber")).Value = order.ItemNumber;
item.AppendChild(xml.CreateElement("QTY" )).Value = order.Quantity;
item.AppendChild(xml.CreateElement("WareHouse" )).Value = order.WareHouse;
xml.DocumentElement.AppendChild(item);
}