You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
550 B
Lua
25 lines
550 B
Lua
local M = {}
|
|
-- 不带属性的key-value, CDATA标签用于说明数据不被XML解析器解析
|
|
function M.encode(k, v, cdata)
|
|
local str = '<'..k..'>'
|
|
if type(v) == "table" then
|
|
for kk, vv in pairs(v) do
|
|
str = str .. '\n' .. M.encode(kk, vv, cdata)
|
|
end
|
|
else
|
|
if cdata then
|
|
str = str .. '<![CDATA['..v..']]>'
|
|
else
|
|
str = str .. v
|
|
end
|
|
end
|
|
str = str..'</'..k..'>'
|
|
return str
|
|
end
|
|
|
|
-- 带属性的key-value
|
|
function M.attr_encode()
|
|
-- todo
|
|
end
|
|
return M
|