Jump to content

XML problem


TheIceman1

Recommended Posts

Zkj mi neče izbrisat clan iz "clans.xml"?

function destroyclan () 
local clan = getElementData ( source, "clan" ) 
removeElementData ( source, "clan" ) 
    local clans = xmlLoadFile ("clans.xml") 
    local clansroot = xmlFindChild (clans,"clans",0) 
   if ( clansroot ) then 
    for i,v in ipairs (xmlNodeGetChildren(clansroot)) do 
      local xmlnumber = xmlNodeGetAttribute (v,"clan") 
      xmlDestroyNode ( v ) 
      xmlSaveFile ( clans ) 
      xmlUnloadFile ( clans ) 
end 
end 
end 
addEvent ( "destroyclan", true ) 
addEventHandler ( "destroyclan", root, destroyclan ) 

XML

    "FBI">

Link to comment
xmlLoadFile already returns pointer to the root of the xml file, so you don't need to search 'clans' node again with xmlFindChild. Try to comment the 5th line and rename 'clans' variable to 'clansroot' in the 4th line and see if that helps.

^ Prateći te upute, dobiješ ovo:

function destroyclan () 
    local clan = getElementData ( source, "clan" ) 
    removeElementData ( source, "clan" ) 
    local clansroot = xmlLoadFile ("clans.xml") 
    -- local clansroot = xmlFindChild (clans,"clans",0) 
    if ( clansroot ) then 
        for i,v in ipairs (xmlNodeGetChildren(clansroot)) do 
            local xmlnumber = xmlNodeGetAttribute (v,"clan") 
            xmlDestroyNode ( v ) 
            xmlSaveFile ( clans ) 
            xmlUnloadFile ( clans ) 
        end 
    end 
end 
addEvent ( "destroyclan", true ) 
addEventHandler ( "destroyclan", root, destroyclan ) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...