XmlFindChild: Difference between revisions
Jump to navigation
Jump to search
(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...) |
(→Example: Removed references to very very old functions that don't exist, changed to be generic rather than referencing an equally old map format.) |
||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
If you wanted to find | If you wanted to find an 'instructions' node in an xml file like this: | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
< | <root version="2.0"> | ||
<options> | <options> | ||
<instructions>Start at the beginning and keep going until the end!</instructions> | <instructions>Start at the beginning and keep going until the end!</instructions> | ||
</options> | </options> | ||
</ | </root> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You could use the following code: | You could use the following code: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
root = xmlLoadFile("test.xml") | |||
optionsnode = xmlFindChild ( | optionsnode = xmlFindChild ( root, "options", 0 ) | ||
instructionsnode = xmlFindChild ( optionsnode, "instructions", 0 ) | instructionsnode = xmlFindChild ( optionsnode, "instructions", 0 ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
==See Also== | ==See Also== | ||
{{XML functions}} | {{XML functions}} |
Revision as of 23:07, 13 June 2009
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 [-]
ServerIf you wanted to find an 'instructions' node in an xml file like this:
<root version="2.0"> <options> <instructions>Start at the beginning and keep going until the end!</instructions> </options> </root>
You could use the following code:
root = xmlLoadFile("test.xml") optionsnode = xmlFindChild ( root, "options", 0 ) instructionsnode = xmlFindChild ( optionsnode, "instructions", 0 )
See Also
- xmlCopyFile
- xmlCreateChild
- xmlCreateFile
- xmlDestroyNode
- xmlFindChild
- xmlLoadFile
- xmlLoadString
- xmlNodeGetAttribute
- xmlNodeGetAttributes
- xmlNodeGetChildren
- xmlNodeGetName
- xmlNodeGetParent
- xmlNodeGetValue
- xmlNodeSetAttribute
- xmlNodeSetName
- xmlNodeSetValue
- xmlSaveFile
- xmlUnloadFile