Sono nuovo a XML
e ho provato quanto segue, ma ricevo un'eccezione. Qualcuno può aiutarmi?Questa operazione creerebbe un documento strutturato in modo errato
L'eccezione è This operation would create an incorrectly structured document
Il mio codice:
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);
}
Quale errore avete? –