创建XML

时间:2021-05-19 04:27:56
//创建XML
XElement xelement = new XElement("request",
new XElement("head",
new XElement("msgId", System.Guid.NewGuid().ToString()),//
new XElement("timeStamp", string.Format("{0:yyyyMMddHHmmssfffff}", DateTime.Now)),
new XElement("session", ""),
new XElement("userCode", "")),// new XElement("body",
new XElement("vehicle",
new XElement("brandName", brandName))));//车型名称
string RequestCarsXML = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>{0}{1}", System.Environment.NewLine, xelement.ToString());