node:contents

March 26, 2020

Name

node:contents — Get or set a text node

Synopsis

require('xml');

node:contents(text_str);

text_str: string (optional)

Description

When a parameter is passed, a text node with the specified value is created. If no string is passed, the value of the text node is returned. To remove text, pass an empty string.

local node = doc:root();
local child = node:addchild("item");
child:contents("I am a child node.");

Note

In the preceding example, the element node , holds a child text node with the value "I am a child node". node:contents() will return the value of the text node of . "I am a child node" is not the value of the element. This is evident if you look at “node:name example”".

See Also

xml.parsexml