XmlSaveFile: Difference between revisions
Jump to navigation
Jump to search
Line 18: | Line 18: | ||
xmlSaveFile( node ) --Save the xml file | xmlSaveFile( node ) --Save the xml file | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<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"> | |||
-- 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) | |||
end | |||
addCommandHandler("createfile", createFileHandler) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{XML_functions}} | {{XML_functions}} |
Revision as of 13:31, 10 November 2010
This function saves a loaded XML file.
Syntax
bool xmlSaveFile ( xmlnode rootNode )
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
This example loads an XML file then saves it again. The file should contain the same data, though it is possible that the order of the tags and/or the order of the attributes may have changed.
node = xmlLoadFile ( "test.xml" ) --load an xml file xmlSaveFile( node ) --Save the xml file
Click to collapse [-]
ClientThis 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) end addCommandHandler("createfile", createFileHandler)
See Also
- xmlCopyFile
- xmlCreateChild
- xmlCreateFile
- xmlDestroyNode
- xmlFindChild
- xmlLoadFile
- xmlLoadString
- xmlNodeGetAttribute
- xmlNodeGetAttributes
- xmlNodeGetChildren
- xmlNodeGetName
- xmlNodeGetParent
- xmlNodeGetValue
- xmlNodeSetAttribute
- xmlNodeSetName
- xmlNodeSetValue
- xmlSaveFile
- xmlUnloadFile