- Documentation
- Shared functions
- xmlCopyFile
Function
xmlCopyFile
Copies a node (with its children and attributes) into a new document at a new path. The copied node becomes the root of the new document, which must be saved with xmlSaveFile.
Syntax
xmlnode xmlCopyFile(xmlnode nodeToCopy, string newFilePath)Arguments
nodeToCopyxmlnode- The node to copy.
newFilePathstring- The new file path.
Returns
The copy's root node, or false.
Example
local root = xmlLoadFile("config.xml")
local backup = xmlCopyFile(root, "config_backup.xml")
xmlSaveFile(backup)
xmlUnloadFile(backup)
xmlUnloadFile(root)
See also
xmlCreateFileCreates a new XML document with a root node of the given name. The document is in memory; it reaches the disk only afterxmlSaveFile. An existing file is overwritten on save.xmlSaveFileSaves the whole document (that the node belongs to) to its file. Does not work for read-only documents or those fromxmlLoadString.