XmlCreateFile: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 20: Line 20:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
xmlnode xmlCreateFile ( string filePath, string rootNodeName [, string accessType = "public" ] )
xmlnode xmlCreateFile ( string filePath, string rootNodeName )
</syntaxhighlight>  
</syntaxhighlight>  


Line 29: Line 29:
:Note that if a different resource than default is being accessed, the caller resource needs access to general.ModifyOtherObjects in the [[ACL]].
:Note that if a different resource than default is being accessed, the caller resource needs access to general.ModifyOtherObjects in the [[ACL]].
*'''rootNodeName:''' the name of the root node in the XML document.
*'''rootNodeName:''' the name of the root node in the XML document.
{{New feature|3.0110|1.1|
===Optional Arguments===
*'''accessType :''' This setting determines whether to create a public or private version of the file at '''filePath'''.
** "public" will create a file that is shared by all servers.
** "private" will create a file that only the current server is allowed to access.
}}
</section>
</section>



Revision as of 23:39, 16 July 2011

This function creates a new XML document, which can later be saved to a file by using xmlSaveFile. This function will overwrite the file specified if it already exists.

Syntax

Click to collapse [-]
Server
xmlnode xmlCreateFile ( string filePath, string rootNodeName )

Required Arguments

  • filePath: The filepath of the file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file will be in, and 'path' is the path from the root directory of the resource to the file.
For example, if you want to create a file named 'new.xml' in the resource 'ctf', it can be created from another resource this way: xmlCreateFile(":ctf/new.xml", "newroot").
If the file is in the current resource, only the file path is necessary, e.g. xmlCreateFile("new.xml", "newroot").
Note that if a different resource than default is being accessed, the caller resource needs access to general.ModifyOtherObjects in the ACL.
  • rootNodeName: the name of the root node in the XML document.
Click to collapse [-]
Client
xmlnode xmlCreateFile ( string filePath, string rootNodeName )

Required Arguments

  • filePath: The filepath of the file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file will be in, and 'path' is the path from the root directory of the resource to the file.
For example, if you want to create a file named 'new.xml' in the resource 'ctf', it can be created from another resource this way: xmlCreateFile(":ctf/new.xml", "newroot").
If the file is in the current resource, only the file path is necessary, e.g. xmlCreateFile("new.xml", "newroot").
Note that if a different resource than default is being accessed, the caller resource needs access to general.ModifyOtherObjects in the ACL.
  • rootNodeName: the name of the root node in the XML document.

Returns

Returns the root xmlnode object of the new XML file if successful, or false otherwise.

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)
end

addCommandHandler("createfile", createFileHandler)

See Also