Just iterate over all children of the level tag (unless there is other information in there you aren't telling us about that needs to be filtered)
require 'luaxml'
local text = [[
<level>
<bg>details1</bg>
<bg>details2</bg>
</level>
]]
local VALUE = 1
local txml = xml.eval(text)
for _, node in pairs(txml:find("level")) do
if node.TAG ~= nil then
print(node[VALUE])
end
end
and if you need to filter out everything except for the <bg>
tags, you can just slightly modify the loop to this:
for _, node in pairs(txml:find("level")) do
if node.TAG ~= nil then
if node[node.TAG] == "bg" then
print(node[VALUE])
end
end
end