Difference between revisions of "XmlCopyFile"

From Multi Theft Auto: Wiki
m
Line 4: Line 4:
  
 
==Syntax==  
 
==Syntax==  
<section name="Server" class="server" show="true">
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
xmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilename, [ resource inResource = getThisResource() ] )
+
xmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilePath )
 
</syntaxhighlight>  
 
</syntaxhighlight>  
  
 
===Required Arguments===  
 
===Required Arguments===  
 
*'''nodeToCopy:''' the [[xmlnode]] that is to be copied to a new document.
 
*'''nodeToCopy:''' the [[xmlnode]] that is to be copied to a new document.
*'''newFilename:''' the path for the new XML 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")''.
===Optional Arguments===
+
:If the file is to be in the current resource, only the file path is necessary, e.g. ''xmlCopyFile(myNode, "newfile.xml")''.
{{OptionalArg}}
 
*'''inResource:''' the [[resource]] whose directory will be used as the root for the filename specified. Note that if a different resource than default is being accessed, the caller resource needs access to general.ModifyOtherObjects in the [[ACL]].
 
</section>
 
 
 
<section name="Client" class="client" show="true">
 
<syntaxhighlight lang="lua">
 
xmlnode xmlCopyFile ( xmlnode nodeToCopy, string newFilename )
 
</syntaxhighlight>
 
 
 
===Required Arguments===
 
*'''nodeToCopy:''' the [[xmlnode]] that is to be copied to a new document.
 
*'''newFilename:''' the [[filepath]] for the new XML document.
 
</section>
 
  
 
===Returns===
 
===Returns===

Revision as of 02:35, 30 July 2009

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

xmlnode 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").

Returns

Returns a xmlnode if the node was successfully copied, false if invalid arguments were passed.

Example

See Also

BETA: FROM VERSION 1.5.7 r19626 ONWARDS