我是XML
的新手,嘗試了以下操作,但出現異常。有人能幫我嗎?此操作將創建一個結構錯誤的文檔
唯一的例外是This operation would create an incorrectly structured document
我的代碼:
string strPath = Server.MapPath("sample.xml");
XDocument doc;
if (!System.IO.File.Exists(strPath))
{
doc = new XDocument(
new XElement("Employees",
new XElement("Employee",
new XAttribute("id", 1),
new XElement("EmpName", "XYZ"))),
new XElement("Departments",
new XElement("Department",
new XAttribute("id", 1),
new XElement("DeptName", "CS"))));
doc.Save(strPath);
}
讓你有什麼錯誤我正確的代碼? –