XmlCreateSubNode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 15: Line 15:


==Example==
==Example==
[[Category:Needs Example]]
<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">
function()
    config = xmlLoadFile("config.xml")
    local newNode = xmlCreateSubNode ( config, "newnode" )
    xmlNodeSetValue ( newNode, "somevalue" )
    xmlSaveFile( config )
end
</syntaxhighlight>


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

Revision as of 09:38, 24 May 2010

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does.

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

<section name="Server" class="server" show="true"> 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