XmlFindChild

From Multi Theft Auto: Wiki
Revision as of 12:00, 6 April 2008 by Arc (talk | contribs) (New page: __NOTOC__ {{Server client function}} This function returns a named child node of an XML node. ==Syntax== <syntaxhighlight lang="lua">xmlnode xmlFindChild ( xmlnode parent, string tagName, int index )</cod...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function returns a named child node of an XML node.

Syntax

xmlnode xmlFindChild ( xmlnode parent, string tagName, int index )

Required Arguments

  • parent: This is an xmlnode that you want to find the child node under.
  • tagName: This is the name of the child node you wish to find.
  • index: This is the 0-based index of the node you wish to find. For example, to find the 5th subnode with a particular name, you would use 4 as the index value. To find the first occurence, use 0.

Returns

Returns an xmlnode if the node was found, false otherwise.

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 beginning and keep going until the end!</instructions>
      </options>
</map>

You could use the following code:

maproot = getLoadedMapXMLRoot ()
optionsnode = xmlFindChild ( maproot, "options", 0 )
instructionsnode = xmlFindChild ( optionsnode, "instructions", 0 )

Note: You could use getMapOption to do the same thing.

See Also