function xml.escape()

From wiki.netio-products.com
Jump to navigation Jump to search

Escapes XML string to fit xml node contents.

string xml.escape(string xml)

Parameters

  • string xml string to escape

Return value

string

Escaped characters are

input output
< &lt;
> &gt;
" &quot;
' &apos;
& &amp;

Usage

-- escape string
local note = xml.escape("3<5")
-- put the escaped string "3<5" into xml node
local node = "<note>"..note.."</note>"
-- parse the node
local result = xml.parse(node)
-- check the contents (text is unescaped: "3<5")
log(result.text)

See also