Comparison

util/stanza.lua @ 1420:1576a5aa52f8

util.stanza: Add stanza:get_text() to retrieve all child text nodes #api
author Matthew Wild <mwild1@gmail.com>
date Fri, 26 Jun 2009 05:54:55 +0100
parent 1416:f916f0ff90e5
child 1431:9fe9ba693f4a
comparison
equal deleted inserted replaced
1419:1ac8bcc63a9d 1420:1576a5aa52f8
156 for k, v in pairs(t.attr) do if type(k) == "string" then attr_string = attr_string .. s_format(" %s='%s'", k, xml_escape(tostring(v))); end end 156 for k, v in pairs(t.attr) do if type(k) == "string" then attr_string = attr_string .. s_format(" %s='%s'", k, xml_escape(tostring(v))); end end
157 end 157 end
158 return s_format("<%s%s>", t.name, attr_string); 158 return s_format("<%s%s>", t.name, attr_string);
159 end 159 end
160 160
161 function stanza_mt.get_text(t)
162 if #t.tags == 0 then
163 return t_concat(t);
164 end
165 end
166
161 function stanza_mt.__add(s1, s2) 167 function stanza_mt.__add(s1, s2)
162 return s1:add_direct_child(s2); 168 return s1:add_direct_child(s2);
163 end 169 end
164 170
165 171