XmlCopyFile: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
|||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
xmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilePath ) | xmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilePath ) | ||
Line 13: | Line 14: | ||
:For example, to create a file named 'newfile.xml' with myNode as the root node in the resource 'ctf', it can be done from another resource this way: ''xmlCopyFile(myNode, ":ctf/newfile.xml")''. | :For example, to create a file named 'newfile.xml' with myNode as the root node in the resource 'ctf', it can be done from another resource this way: ''xmlCopyFile(myNode, ":ctf/newfile.xml")''. | ||
:If the file is to be in the current resource, only the file path is necessary, e.g. ''xmlCopyFile(myNode, "newfile.xml")''. | :If the file is to be in the current resource, only the file path is necessary, e.g. ''xmlCopyFile(myNode, "newfile.xml")''. | ||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
xmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilePath [, string accessType = "public" ] ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''nodeToCopy:''' the [[xmlnode]] that is to be copied to a new document. | |||
*'''newFilePath:''' the path of the file that is to be created, in the following format: '''":resourceName/path"'''. 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. | |||
:For example, to create a file named 'newfile.xml' with myNode as the root node in the resource 'ctf', it can be done from another resource this way: ''xmlCopyFile(myNode, ":ctf/newfile.xml")''. | |||
:If the file is to be in the current resource, only the file path is necessary, e.g. ''xmlCopyFile(myNode, "newfile.xml")''. | |||
{{New feature|3.0110|1.1| | |||
===Optional Arguments=== | |||
*'''accessType :''' This setting determines whether to create a public or private version of the file at '''newFilePath''' | |||
** "public" will create a file that can be accessed by all servers. | |||
** "private" will create a file that can only be accessed by the current server. | |||
}} | |||
</section> | |||
===Returns=== | ===Returns=== |
Revision as of 13:19, 1 June 2011
This function copies all contents of a certain node in a XML document to a new document file, so the copied node becomes the new file's root node.
Syntax
Click to collapse [-]
Serverxmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilePath )
Required Arguments
- nodeToCopy: the xmlnode that is to be copied to a new document.
- newFilePath: the path of the file that is to be created, in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
- For example, to create a file named 'newfile.xml' with myNode as the root node in the resource 'ctf', it can be done from another resource this way: xmlCopyFile(myNode, ":ctf/newfile.xml").
- If the file is to be in the current resource, only the file path is necessary, e.g. xmlCopyFile(myNode, "newfile.xml").
Click to collapse [-]
Clientxmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilePath [, string accessType = "public" ] )
Required Arguments
- nodeToCopy: the xmlnode that is to be copied to a new document.
- newFilePath: the path of the file that is to be created, in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
- For example, to create a file named 'newfile.xml' with myNode as the root node in the resource 'ctf', it can be done from another resource this way: xmlCopyFile(myNode, ":ctf/newfile.xml").
- If the file is to be in the current resource, only the file path is necessary, e.g. xmlCopyFile(myNode, "newfile.xml").
Optional Arguments
- accessType : This setting determines whether to create a public or private version of the file at newFilePath
- "public" will create a file that can be accessed by all servers.
- "private" will create a file that can only be accessed by the current server.
Returns
Returns a xmlnode if the node was successfully copied, false if invalid arguments were passed.
Example
In this example we will load an xml file (in the example config.xml) and create a copy in a new folder with the name of copy-config.xml:
local config = xmlLoadFile("config.xml") xmlCopyFile(config, "copy/copy-config.xml")
See Also
- xmlCopyFile
- xmlCreateChild
- xmlCreateFile
- xmlDestroyNode
- xmlFindChild
- xmlLoadFile
- xmlLoadString
- xmlNodeGetAttribute
- xmlNodeGetAttributes
- xmlNodeGetChildren
- xmlNodeGetName
- xmlNodeGetParent
- xmlNodeGetValue
- xmlNodeSetAttribute
- xmlNodeSetName
- xmlNodeSetValue
- xmlSaveFile
- xmlUnloadFile