XmlNodeGetChildren

From Multi Theft Auto: Wiki
Revision as of 11:22, 28 February 2008 by EAi (talk | contribs)
Jump to navigation Jump to search

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