Hi there, I am trying to implement a error system, and i am stuck on the problem, that xmlCreateChild overwrites the old node and so i cant get an error-list.
Here is the Code:
[lua]--------------------------------------------------Fehler in XML speichern--------------------------------------------------
function registerError( errorType, errorDescription )
local xmlErrorLog = xmlLoadFile( "errorLog.xml" )
if xmlErrorLog == false then
xmlErrorLog = xmlCreateFile( "errorLog.xml", "errors" )
end
local time = getRealTime( ) -- Die Zeit des Fehlers
local timeString = "" .. time["year"]+1900 .. "." .. time["month"]+1 .. "." .. time["monthday"] .. "-" .. time["hour"] .. "." .. time["minute"] .. "." .. time["second"]
local xmlNewError = xmlCreateChild( xmlErrorLog, timeString )
xmlNodeSetAttribute( xmlNewError, "type", errorType )
xmlNodeSetAttribute( xmlNewError, "description", errorDescription )
xmlSaveFile( xmlErrorLog )
xmlUnloadFile( xmlErrorLog )
end
addEvent( "registerError" )
addEventHandler( "registerError", root, registerError )[/lua]
The node should have been the timestamp, as the "new" node needs a new name, but it doesnt work (old nodes get overwriten).
Edit: and somehow the [lua] [/lua] code syntax does not work? Sorry for that too!