4 回答
TA贡献1806条经验 获得超8个赞
using System.Xml.Linq;
XDocument input = XDocument.Load(".\\input.xml");
XDocument output = new XDocument(
new XElement("NewDataSet",
new XElement("Table")));
foreach (var tb in input.Element("NewDataSet").Elements()) {
output.Element("NewDataSet").Element("Table").Add(new XElement("Data",
new XAttribute("UserID", tb.Element("UserID").Value),
new XAttribute("DialerStatisticsStatusID", tb.Element("DialerStatisticsStatusID").Value),
new XAttribute("BeginDate", tb.Element("BeginDate").Value),
new XAttribute("EndDate", tb.Element("EndDate").Value),
new XAttribute("TimeSpent", tb.Element("TimeSpent").Value)));
}
output.Save(".\\output.xml");
TA贡献1942条经验 获得超3个赞
using (StringWriter sw = new StringWriter())
{
XmlSerializer xz = new XmlSerializer(Student.GetType());
xz.Serialize(sw, Student);
sw.ToString();
}
- 4 回答
- 0 关注
- 1693 浏览
添加回答
举报