XmlNodeGetValue: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
{{Needs_Checking|Example outdated. xmlFindSubNode no longer exists.}}
__NOTOC__  
__NOTOC__  
This function is made to be able to read tag values in XML files (eg. <something>anything</something>).
This function is made to be able to read tag values in XML files (eg. <something>anything</something>).

Revision as of 07:44, 24 November 2010

Dialog-information.png This article needs checking.

Reason(s): Example outdated. xmlFindSubNode no longer exists.

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