function implicitCast(data)
if( data == "true" ) then
return true; end;
if( data == "false" ) then
return false; end;
if( string.find(data, "[^%.?0-9+]") == nil ) then
return tonumber(data);
end
-- convert hex string to number.
if( string.find(data, "^(0x%x+)$") ~= nil) then
--print ("data: ", data)
return tonumber(data:sub(3), 16);
end
return data;
end
I have several uses for it so I think it's pretty useful to include it in the XML lua parser.