XmlNodeGetValue

From Multi Theft Auto: Wiki
Revision as of 13:58, 26 March 2009 by Awwu (talk | contribs)
Jump to navigation Jump to search

This function is made to be able to read tag values in XML files (eg. <something>anything</something>).

Syntax

string xmlNodeGetValue ( xmlnode theXMLNode )             

Required Arguments

  • theXMLNode: The xml node of which you need to know the value.

Returns

Returns the value of the node as a string if it was received successfully, false otherwise.

Example

In this example a sample value is returned from a XML file.

local xmlFile = xmlLoadFile ( "exampleFile.xml" ) -- Open a file that we have already created
if xmlFile then -- If it's indeed opened
    local node = xmlFindSubNode ( xmlFile, "somesubnode", 0 ) -- Find our first sub node
    local success = xmlNodeGetValue ( node ) -- Get the value of it
    if success then -- Check if it was successful
        outputChatBox ( tostring ( success ) ) -- Output "somevalue" to the chatbox
    end
end

In order for the result to be valid, the xml file has to look like this:

Click to collapse [-]
exampleFile.xml
<somenode>
        <somesubnode>somevalue</somesubnode>
</somenode>

See Also