9951 explained code solutions for 126 technologies


luaHow to parse XML


local xml = require "xml"
local data = xml.load('<xml_string>')ctrl + c
require "xml"

load xml module to work with XML

xml.load

parse given XML string and return object to access parsed data

'<xml_string>'

sample XML string


Usage example

local xml = require "xml"
local data = xml.load [[
<?xml?>
<person>
  <name>Donald</name>
</person>
]]

local prop = xml.find(data, 'name')
print(prop[1])
output
Donald