Software /
code /
prosody
Changeset
4132:ccc16434dbe2
util.stanza: Add get_child_text() method to get the text of the specified child element (get_child() + get_text() rolled into one step)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 31 Jan 2011 13:05:49 +0000 |
parents | 4130:c3508071af47 |
children | 4133:71b38dca22c3 4135:9dfb3c0101b5 |
files | util/stanza.lua |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/stanza.lua Sat Jan 29 04:42:56 2011 +0500 +++ b/util/stanza.lua Mon Jan 31 13:05:49 2011 +0000 @@ -108,6 +108,14 @@ end end +function stanza_mt:get_child_text(name, xmlns) + local tag = self:get_child(name, xmlns); + if tag then + return tag:get_text(); + end + return nil; +end + function stanza_mt:child_with_name(name) for _, child in ipairs(self.tags) do if child.name == name then return child; end