From 22bd191f8634a478a7b2ca1a020270471bcd08c6 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 31 Jan 2011 13:05:49 +0000 Subject: util.stanza: Add get_child_text() method to get the text of the specified child element (get_child() + get_text() rolled into one step) --- util/stanza.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/stanza.lua') diff --git a/util/stanza.lua b/util/stanza.lua index afaf9ce9..79c1a71e 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -108,6 +108,14 @@ function stanza_mt:get_child(name, xmlns) 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 -- cgit v1.2.3