xmlCreateChild | Multi Theft Auto: Wiki Skip to content

xmlCreateChild

Client-side
Server-side
Shared

This function creates a new child node under an XML node.

OOP Syntax Help! I don't understand this!

Syntax

xmlnode|false xmlCreateChild ( xmlnode parentNode, string tagName )
Required Arguments
  • parentNode: The xmlnode you want to create a new child node under.
  • tagName: The type of the child node that will be created.

Returns

  • xmlnode|false: xmlnode

Returns the created xmlnode if successful, false otherwise.

Code Examples

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")
if (not RootNode) then
return
end
local NewNode = xmlCreateChild(RootNode, "newchild")
if (not NewNode) then
return
end
xmlSaveFile(RootNode)
xmlUnloadFile(RootNode)
end
addCommandHandler("createfile", createFileHandler)