3 个解决方案
#2
学习一下这个方法吧
http://www.cnblogs.com/yukaizhao/archive/2011/07/21/linq-to-xml.html
http://www.cnblogs.com/yukaizhao/archive/2011/07/21/linq-to-xml.html
#3
简单点;
生成xml文件
然后保存:
ComputerEntity entity = tree.CurrentBaseEntity as ComputerEntity;
XElement groupElement = new XElement("Group", new XAttribute("Name", entity.GroupName));
XElement carsElement = new XElement("Cars", new XAttribute("Name", entity.CollectionName));
XElement carElement = new XElement("Car",
new XAttribute("Id", entity.Id),
new XAttribute("Width", entity.Width),
new XAttribute("Height", entity.Height),
new XAttribute("IsSelected", entity.IsSelected.ToString()),
new XAttribute("CollectionName", entity.CollectionName),
new XAttribute("GroupName", entity.GroupName),
new XElement("Name", entity.Name),
new XElement("IP", entity.IP),
new XElement("X", entity.X),
new XElement("Y", entity.Y)
);
carsElement.Add(carElement);
groupElement.Add(carsElement);
this.xmlDoc.Add(groupElement);
生成xml文件
然后保存:
XElement.Save(路径)
#1
#2
学习一下这个方法吧
http://www.cnblogs.com/yukaizhao/archive/2011/07/21/linq-to-xml.html
http://www.cnblogs.com/yukaizhao/archive/2011/07/21/linq-to-xml.html
#3
简单点;
生成xml文件
然后保存:
ComputerEntity entity = tree.CurrentBaseEntity as ComputerEntity;
XElement groupElement = new XElement("Group", new XAttribute("Name", entity.GroupName));
XElement carsElement = new XElement("Cars", new XAttribute("Name", entity.CollectionName));
XElement carElement = new XElement("Car",
new XAttribute("Id", entity.Id),
new XAttribute("Width", entity.Width),
new XAttribute("Height", entity.Height),
new XAttribute("IsSelected", entity.IsSelected.ToString()),
new XAttribute("CollectionName", entity.CollectionName),
new XAttribute("GroupName", entity.GroupName),
new XElement("Name", entity.Name),
new XElement("IP", entity.IP),
new XElement("X", entity.X),
new XElement("Y", entity.Y)
);
carsElement.Add(carElement);
groupElement.Add(carsElement);
this.xmlDoc.Add(groupElement);
生成xml文件
然后保存:
XElement.Save(路径)