rendered paste bodyThe error :
This operation would create an incorrectly structured document.
The Code :
public static void Ecrire_Log(string IP, string UserID, string Guid, string Fonction, string Information)
{
XDocument doc = XDocument.Load("C:\\xmllog.xml");
/*
CFER_Log log = new CFER_Log() { IP = IP,
UserID = UserID,
Guid = Guid,
Fonction = Fonction,
Information = Information };*/
XElement XML_log = new XElement("log",
new XElement("IP", IP),
new XElement("UserID", UserID),
new XElement("Guid", Guid),
new XElement("Fonction", Fonction),
new XElement("Information", Information));
//XElement XML_log = new XElement("logs",IP, UserID, Guid, Fonction, Information);
doc.AddFirst(XML_log);
doc.Save("C:\\xmllog.xml");
//XML_log.Save("c:\\xmllog.xml");
}
The XML Doc..
<?xml version="1.0" encoding="utf-8"?>
<logs>
<log>
<IP>127.0.0.1</IP>
<UserID>berdav</UserID>
<Guid>someguid</Guid>
<Fonction>somefunction</Fonction>
<Information>someaction</Information>
</log>
</logs>