# HG changeset patch # User Matthew Wild # Date 1296479149 0 # Node ID ccc16434dbe261c6fe9f393342afa5e1120f2d3f # Parent c3508071af47414374217ec37df2e0d6cdd0cf02 util.stanza: Add get_child_text() method to get the text of the specified child element (get_child() + get_text() rolled into one step) diff -r c3508071af47 -r ccc16434dbe2 util/stanza.lua --- 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