9951 explained code solutions for 126 technologies


luaHow to convert table to XML string


local xml = require "xml"
local xml_string = xml.dump(tbl)ctrl + c
require "xml"

load xml module to work with XML

xml.dump

converts given table to XML string

tbl

sample table to convert to XML string

xml_string

resulting string with XML


Usage example

local xml = require "xml"
local tbl = {xml = 'person', name="Donald"}
local xml_string = xml.dump(tbl)
print(xml_string)
output
<person name='Donald'/>