Node:add(name, [text])method

Adds a new child node with the specified name and optional text content.

Parameters

name

A string representing the name of the child node.

[text]

An optional string representing the content for the child node.

Return value

Returns the newly added Node object.

Example

local xml = require 'xml' local root = xml.Node("root") local child = root:add("child", "content") print(root) -- child have been added