how to save a CDATA tag by using module LuaXml or using other lua xml module



[1] how to save a CDATA tag by using module LuaXml or using other lua xml module



--package.path = package.path ..";".."lib/?.lua"
--package.cpath = package.cpath ..";".."lib/?.dll"

require('LuaXml')

local code = [[
if ${condition} then
${cursor}
end
]]

local cdata_tag = string.format("<![CDATA[%s]]>", code)

print(cdata_tag)

local root = xml.new("templates")
local templ = root:append("template")
templ:append("content")[1] = cdata_tag

print(root)

--[==[
-- print(cdata_tag)
<![CDATA[if ${condition} then
${cursor}
end
]]>

-- print(root)
<templates>
<template>
<content>&lt;![CDATA[if ${condition} then
${cursor}
end
]]&gt;</content>
</template>
</templates>

--]==]


but, it's not expacting. I want to save xml like this:



<content><![CDATA[if ${condition} then
${cursor}
end</content>


[2] how to using API, xml.registerCode and xml.encode, I have look up the lua51\docs\luaxml\readme.txt , but can not understand it.


No comments:

Post a Comment