亲:
对不住!
这个东西只是解析.
json 字符串进过字符串分析处理后遍历后加入到xml文件中.
这里给你xml的操作代码- XmlDocument xml = new XmlDocument();
- //添加文档声明
- XmlDeclaration dec = xml.CreateXmlDeclaration("1.0", "utf-8", null);
- xml.AppendChild(dec);
- //生成根节点
- XmlElement order = xml.CreateElement("order");
- xml.AppendChild(order);
- //客户名称
- XmlElement customerName = xml.CreateElement("CustomerName");
- customerName.InnerText = "nl";
- order.AppendChild(customerName);
- //订单编号
- XmlElement orderNo = xml.CreateElement("OrderNo");
- orderNo.InnerText = "000001";
- order.AppendChild(orderNo);
- //items
- XmlElement items = xml.CreateElement("Items");
- order.AppendChild(items);
- //orderItem1
- XmlElement orderItem = xml.CreateElement("OrderItem");
- orderItem.SetAttribute("Name", "电脑");
- orderItem.SetAttribute("Count", "9");
- items.AppendChild(orderItem);
- //orderItem2
- XmlElement orderItem2 = xml.CreateElement("OrderItem");
- orderItem2.SetAttribute("Name", "电视");
- orderItem2.SetAttribute("Count", "2");
- items.AppendChild(orderItem2);
- //
- 保存
- xml.Save("order.xml");
复制代码 |