XmlNodeSetValue: Difference between revisions

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

Revision as of 19:18, 26 November 2010

Dialog-information.png This article needs checking.

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

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

Syntax

bool xmlNodeSetValue ( xmlnode theXMLNode, string value )            

Required Arguments

  • theXMLNode: The xml node you want to set the value of.
  • value: The string value you want the node to have.

Returns

Returns true if value was successfully set, false otherwise.

Example

In this example a sample value is inserted into a XML file.

local xmlFile = xmlLoadFile ( "exampleFile.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

After both changing the value and saving the XML file with xmlSaveFile, the file will look like this:

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

See Also