Skip to main content

Name

doc:root — Return the root node of an XML document

Synopsis

require('xml');

doc:root();

Description

Where doc is an XML object created using xml.parsexml, return the root node.

local doc = xml.parsexml([[<doc></doc>]]);
local node = doc:root();
local child = node:addchild("item");
child:contents("I am a child node.");
print(node:tostring());

See Also

Was this page helpful?