Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Customer newCustomer = new Customer();
- Console.WriteLine("Please Enter new Customer Id");
- int id = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Please Enter The Customers First Name:");
- string firstName = Console.ReadLine();
- Console.WriteLine("Please Enter The Customers Surname:");
- string lastName = Console.ReadLine();
- Console.WriteLine("Please Enter a Contact Telephone Number:");
- string phoneNumber = Console.ReadLine();
- Console.WriteLine("Please Enter The First Line of the Delivery Address:");
- string firstLineAddress = Console.ReadLine();
- Console.WriteLine("Please Enter Second Line of the Address:");
- string secondLineAddress = Console.ReadLine();
- Console.WriteLine("Please Enter Town / City:");
- string townCity = Console.ReadLine();
- Console.WriteLine("Please Enter Postcode");
- string postCode = Console.ReadLine();
- Console.WriteLine("Please Enter Customers Email Address");
- string emailAddress = Console.ReadLine();
- XDocument doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
- new XComment("Customer Database"),
- new XElement("customer", new XAttribute("CustomerId", id),
- new XElement("firstName", firstName),
- new XElement("lastName", lastName),
- new XElement("firstLineAddress", firstLineAddress),
- new XElement("secondLineAddress", secondLineAddress),
- new XElement("cityTown", townCity),
- new XElement("postCode", postCode),
- new XElement("phoneNumber", phoneNumber),
- new XElement("emailAddress", emailAddress)));
- doc.Save("CustomerDatabase\Customer.xml");
- <?xml version="1.0" encoding="utf-8"?>
- <customer>...</customer>
- <?xml version="1.0" encoding="utf-8"?>
- <customer>...</customer>
- <?xml version="1.0" encoding="utf-8"?>
- <customers>
- <customer>...</customer>
- <customer>...</customer>
- </customers>
- var newCustomer = new XElement("customer", new XAttribute("CustomerId", id),
- new XElement("firstName", firstName),
- new XElement("lastName", lastName),
- new XElement("firstLineAddress", firstLineAddress),
- new XElement("secondLineAddress", secondLineAddress),
- new XElement("cityTown", townCity),
- new XElement("postCode", postCode),
- new XElement("phoneNumber", phoneNumber),
- new XElement("emailAddress", emailAddress)));
- XDocument doc = XDocument.Load("CustomerDatabase\Customer.xml");
- var customers= doc.Element("customers");
- customers.Add(newCustomer);
- doc.Save("CustomerDatabase\Customer.xml");
Add Comment
Please, Sign In to add comment