XmlCreateSubNode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
(8 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Needs_Checking| afaik this is a server only function. i think kev never added it clientside --[[User:Talidan2|Talidan2]] 12:10, 19 October 2007 (CDT) }}
{{Server client function}}
{{Server client function}}
This function returns a named sub node of a particular XML node.
{{Deprecated|xmlCreateChild|}}
 
This function creates a subnode for a specified XML node.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">xmlnode xmlCreateSubNode ( xmlnode, tagname )</syntaxhighlight>
<syntaxhighlight lang="lua">xmlnode xmlCreateSubNode ( xmlnode parentNode, string tagname )</syntaxhighlight>


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''parentNode:''' the [[xmlnode]] you want to create a subnode of.
*'''argumentName:''' description
*'''tagname:''' the type of the subnode that will be created.
 
<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' description
*'''argumentName3:''' description


===Returns===
===Returns===
Returns a table of resources.
Returns the created [[xmlnode]] if successful, ''false'' otherwise.


==Example==
==Example==
This function lists all loaded resources in the console.
<section name="Server" class="server" show="true">
We need to create a new node between the tags <config> and </ config>.
config.xml:
<syntaxhighlight lang="xml">
<config>
    <newnode>somevalue</newnode>
</config>
</syntaxhighlight>
Lua code:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function blabla ()
function()
    --this does blabla
    config = xmlLoadFile("config.xml")
    local newNode = xmlCreateSubNode ( config, "newnode" )
    xmlNodeSetValue ( newNode, "somevalue" )
    xmlSaveFile( config )
end
end
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{XML functions}}
{{XML functions}}

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