XmlNodeGetChildren

From Multi Theft Auto: Wiki
Revision as of 11:11, 6 April 2008 by Norby89 (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 xmlNodeGetChildren( xmlnode parent, [ int index ])

Required Arguments

  • parent: This is an xmlnode that you want to find the children 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 children.

Returns

If index isn't specified, it returns a list of all children. 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 = xmlNodeGetChildren( maproot, 0 ); -- In this case it would find the options sub node as the first under the 'map' node

See Also