diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-01-31 13:05:49 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-01-31 13:05:49 +0000 |
commit | 22bd191f8634a478a7b2ca1a020270471bcd08c6 (patch) | |
tree | d668dc458b5d7b5427b1dd6e31df43d8db9202b3 | |
parent | 4e486d4ba9300c553a7a8fce15037141d48a77f5 (diff) | |
download | prosody-22bd191f8634a478a7b2ca1a020270471bcd08c6.tar.gz prosody-22bd191f8634a478a7b2ca1a020270471bcd08c6.zip |
util.stanza: Add get_child_text() method to get the text of the specified child element (get_child() + get_text() rolled into one step)
-rw-r--r-- | util/stanza.lua | 8 |
1 files changed, 8 insertions, 0 deletions
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 |