你可以創建一個XML文檔C#使用XmlWriter,包含在System.Xml命名空間中。這裏是你如何使用它的一個例子:
using System.Xml;
using System.Collections.Generic;
namespace XmlExample
{
class Program
{
static void Main(string[] args)
{
List<Student> students = new List<Student>();
students.Add(new Student { ID = 1, Name = "Ryan", Grade = 99 });
students.Add(new Student { ID = 2, Name = "Ann", Grade = 84 });
students.Add(new Student { ID = 3, Name = "Rebecca", Grade = 83 });
students.Add(new Student { ID = 4, Name = "Jon", Grade = 26 });
using (XmlWriter xml = XmlWriter.Create("ComputerScience1234.xml"))
{
xml.WriteStartDocument();
xml.WriteStartElement("COSC1234");
foreach (Student s in students)
{
xml.WriteStartElement("Student");
xml.WriteElementString("ID", s.ID.ToString());
xml.WriteElementString("Name", s.Name);
xml.WriteElementString("Grade", s.Grade.ToString());
xml.WriteEndElement();
}
xml.WriteEndElement();
xml.WriteEndDocument();
}
}
}
}
什麼是LAS文件? – 2011-06-16 13:07:14
它的所有球軸承這些天,寧拉傑 – heisenberg 2011-06-16 13:09:24
1.閱讀你的文件。 2.解析它。 3.將其轉換爲XML。 還剩任何問題? – 0x434D53 2011-06-16 14:12:49