XmlNodeGetChildren: Difference between revisions

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


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">xmlnode/table xmlNodeGetSubNodes( xmlnode parent[, int index])</syntaxhighlight>
<syntaxhighlight lang="lua">xmlnode/table xmlNodeGetSubNodes( xmlnode parent, [ int index ])</syntaxhighlight>


===Required Arguments===
===Required Arguments===

Revision as of 15:23, 28 February 2008

This function returns a single sub node or a list of sub nodes of a particular XML node.

Syntax

xmlnode/table xmlNodeGetSubNodes( xmlnode parent, [ int index ])

Required Arguments

  • parent: This is an xmlnode that you want to find the sub nodes under.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • index: This is the index of the node you wish to find. For example, to find the 5th subnode, you would use 4 as the index value. To find the first occurence, use 0. If this is not set, it will return a list of all sub nodes.

Returns

If index isn't specified, it returns a list of all sub nodes. Returns an xmlnode object if index was set and a node was found, otherwise it returns false.

Example

Click to collapse [-]
Server

If you wanted to find the 'instructions' node in a map file like this:

<map version="2.0">
      <options>
            <instructions>Start at the begining and keep going until the end!</instructions>
      </options>
</map>

You could use the following code:

maproot = getLoadedMapXMLRoot ();
optionsnode = xmlNodeGetSubNodes( maproot, 0 ); -- In this case it would find the options sub node as the first under the 'map' node

See Also