node:attribute

March 26, 2020

Name

node:attribute — Set or get the attribute of a node

Synopsis

require('xml');

node:attribute(name, value);

name: string
value: mixed (optional)

Description

The attribute function can be used to get or set the attribute of a node. Use nil to unset value. node:attr is a synonym for node:attribute.

node:attr("name", "newval") -- sets the "name" attribute to "newval"
node:attr("name", nil) -- clears the "name" attribute
print(node:attr("name")) -- prints the value of the "name" attribute

See Also

xml.parsexml