XmlNodeGetValue: Difference between revisions
Jump to navigation
Jump to search
Paul Cortez (talk | contribs) No edit summary |
|||
Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This | This function is made to be able to read values in XML files. (for example <something>anything</something>) | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 10: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''xmlnode:''' The node of which you need to know the value. | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
{{OptionalArg}} | {{OptionalArg}} | ||
*''' | *'''none:''' | ||
===Returns=== | ===Returns=== | ||
Returns | Returns the value of the node if successful, ''false'' otherwise. | ||
==Example== | ==Example== | ||
In this example is shown what xmlNodeSetValue does and how it works: | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | local xmlFile=xmlLoadFile("xmlfile.xml") --Open a file already created | ||
if xmlFile then --If it's indeed opened: | |||
-- | local node=xmlCreateSubNode(xmlFile,"somesubnode") --Create a new subnode | ||
local success=xmlNodeSetValue(node,"somevalue") --Set the value of it | |||
if success then --Check if it was successful | |||
xmlSaveFile(xmlFile) --Save the file | |||
end --End what still needs to be ended | |||
end | |||
end | |||
</syntaxhighlight> | |||
The xml file wil look like: | |||
<syntaxhighlight lang="xml"> | |||
<somenode> | |||
<somesubnode>somevalue</somesubnode> | |||
</somenode> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 20:24, 10 August 2008
This function is made to be able to read values in XML files. (for example <something>anything</something>)
Syntax
string xmlNodeGetValue ( xmlnode xmlnode )
Required Arguments
- xmlnode: The node of which you need to know the value.
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.
- none:
Returns
Returns the value of the node if successful, false otherwise.
Example
In this example is shown what xmlNodeSetValue does and how it works:
local xmlFile=xmlLoadFile("xmlfile.xml") --Open a file already created if xmlFile then --If it's indeed opened: local node=xmlCreateSubNode(xmlFile,"somesubnode") --Create a new subnode local success=xmlNodeSetValue(node,"somevalue") --Set the value of it if success then --Check if it was successful xmlSaveFile(xmlFile) --Save the file end --End what still needs to be ended end end
The xml file wil look like:
<somenode> <somesubnode>somevalue</somesubnode> </somenode>
See Also
Template:FunctionArea Functions
- xmlCopyFile
- xmlCreateChild
- xmlCreateFile
- xmlDestroyNode
- xmlFindChild
- xmlLoadFile
- xmlLoadString
- xmlNodeGetAttribute
- xmlNodeGetAttributes
- xmlNodeGetChildren
- xmlNodeGetName
- xmlNodeGetParent
- xmlNodeGetValue
- xmlNodeSetAttribute
- xmlNodeSetName
- xmlNodeSetValue
- xmlSaveFile
- xmlUnloadFile