aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-11-30 16:39:27 +0000
committerMatthew Wild <mwild1@gmail.com>2009-11-30 16:39:27 +0000
commit70c975bfe07e639931a0f6e1e21c4783ac6fa5a1 (patch)
treea534a93f2cf59472a99a0808cbcdfe5872d8c1cf /util/stanza.lua
parent8fcbba4b0fccb299121083d97cab065e51fba9d1 (diff)
downloadprosody-70c975bfe07e639931a0f6e1e21c4783ac6fa5a1.tar.gz
prosody-70c975bfe07e639931a0f6e1e21c4783ac6fa5a1.zip
util.stanza: Add stanza:get_child(name, xmlns) to find a child tag given a name/xmlns
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index d295d5cc..8d3b7747 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -93,6 +93,17 @@ function stanza_mt:add_child(child)
return self;
end
+function stanza_mt:get_child(name, xmlns)
+ for _, child in ipairs(self.tags) do
+ if (not name or child.name == name)
+ and ((not xmlns and self.attr.xmlns == child.attr.xmlns)
+ or child.attr.xmlns == xmlns) then
+
+ return child;
+ end
+ end
+end
+
function stanza_mt:child_with_name(name)
for _, child in ipairs(self.tags) do
if child.name == name then return child; end