XmlSaveFile: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Prevented memory leak)
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
{{Server client function}}
This function saves a loaded XML file.
This function saves a loaded XML file.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool xmlSaveFile ( xmlnode rootNode ) </syntaxhighlight>
<syntaxhighlight lang="lua">bool xmlSaveFile ( xmlnode rootNode ) </syntaxhighlight>
 
{{OOP||[[xmlnode]]:saveFile}}
===Required Arguments===  
===Required Arguments===  
*'''rootNode:''' the root [[xmlnode]] of the loaded XML file.
*'''rootNode:''' the root [[xmlnode]] of the loaded XML file.
Line 12: Line 13:


==Example==
==Example==
<section name="Client" class="client" show="true">
This example allows a player to use the command 'createfile' to create an .xml file.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
-- Creates a file named "new.xml" with root node "newroot" and childnode "newchild".
blabhalbalhb --abababa
function createFileHandler()
--This line does this...
local RootNode = xmlCreateFile("new.xml"," newroot")
mooo
local NewNode = xmlCreateChild(RootNode, "newchild")
xmlSaveFile(RootNode)
xmlUnloadFile(RootNode)
end
 
addCommandHandler("createfile", createFileHandler)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{XML_functions}}
{{XML_functions}}
[[Category:Incomplete]]
[[ru:xmlSaveFile]]

Latest revision as of 20:46, 12 May 2019

This function saves a loaded XML file.

Syntax

bool xmlSaveFile ( xmlnode rootNode ) 

OOP Syntax Help! I don't understand this!

Method: xmlnode:saveFile(...)


Required Arguments

  • rootNode: the root xmlnode of the loaded XML file.

Returns

Returns true if save was successful, false if the XML file does not exist.

Example

Click to collapse [-]
Client

This example allows a player to use the command 'createfile' to create an .xml file.

-- Creates a file named "new.xml" with root node "newroot" and childnode "newchild".
function createFileHandler()
local RootNode = xmlCreateFile("new.xml"," newroot")
local NewNode = xmlCreateChild(RootNode, "newchild")
xmlSaveFile(RootNode)
xmlUnloadFile(RootNode)
end

addCommandHandler("createfile", createFileHandler)

See Also