Hi all
I have a project that was working perfectly. I then updated the latest corona build a few days ago (Version 2013.1108 (2013.5.15)). Now when I compile the app I get an error relating to the xml parsing script xmlSimple.lua. I wonder if something has changed in the daily builds that would cause this.
Error:
Runtime error
…x/Corona dev/Mobile App v2.301/classes/xmlSimple.lua:90: attempt to concatenate field ‘name’ (a function value)
Here is the offending chunk from xmlSimple.lua. I mark the line that is an issue with arrows.
[lua]
function XmlParser:ParseXmlText(xmlText)
local stack = {}
local top = newNode()
table.insert(stack, top)
local ni, c, label, xarg, empty
local i, j = 1, 1
while true do
ni, j, c, label, xarg, empty = string.find(xmlText, “<(%/?)([%w_:]+)(.-)(%/?)>”, i)
if not ni then break end
local text = string.sub(xmlText, i, ni - 1);
if not string.find(text, “^%s*$”) then
local lVal = (top:value() or “”) … self:FromXmlString(text)
stack[#stack]:setValue(lVal)
end
if empty == “/” then – empty element tag
local lNode = newNode(label)
self:ParseArgs(lNode, xarg)
top:addChild(lNode)
elseif c == “” then – start tag
local lNode = newNode(label)
self:ParseArgs(lNode, xarg)
table.insert(stack, lNode)
top = lNode
else – end tag
local toclose = table.remove(stack) – remove top
top = stack[#stack]
if #stack < 1 then
error("XmlParser: nothing to close with " … label)
end
if toclose:name() ~= label then
error("XmlParser: trying to close " … toclose.name … " with " … label) --<<<<<<<<<< LINE 90
end
top:addChild(toclose)
end
i = j + 1
end
local text = string.sub(xmlText, i);
if #stack > 1 then
error("XmlParser: unclosed " … stack[#stack]:name())
end
return top
end
[/lua]
I admit that I don’t totally understand what this code is doing so I wonder if anyone can shed any light on why this might be causing a problem now and what I can do to solve it please?
The full xmlSimple.lua file can be found here for reference also: https://github.com/Cluain/Lua-Simple-XML-Parser/blob/master/xmlSimple.lua
The code I am using to call the parser is:
[lua]
local xml = require(“classes.xmlSimple”).newParser()
local refreshXML = xml:ParseXmlText(event.response);
[/lua]
event.response is a server response in xml format called via a network request.
Thank you to anyone who can help!
Dougi