XmlCreateSubNode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Replaced Deprecated template with DeprecatedWithAlt)
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
{{DeprecatedWithAlt|xmlCreateChild|}}
{{Deprecated|xmlCreateChild|}}


This function creates a subnode for a specified XML node.
This function creates a subnode for a specified XML node.

Latest revision as of 16:33, 13 February 2015

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use xmlCreateChild instead.


This function creates a subnode for a specified XML node.

Syntax

xmlnode xmlCreateSubNode ( xmlnode parentNode, string tagname )

Required Arguments

  • parentNode: the xmlnode you want to create a subnode of.
  • tagname: the type of the subnode that will be created.

Returns

Returns the created xmlnode if successful, false otherwise.

Example

Click to collapse [-]
Server

We need to create a new node between the tags <config> and </ config>. config.xml:

<config>
    <newnode>somevalue</newnode>
</config>

Lua code:

function()
    config = xmlLoadFile("config.xml")
    local newNode = xmlCreateSubNode ( config, "newnode" )
    xmlNodeSetValue ( newNode, "somevalue" )
    xmlSaveFile( config )
end

See Also