aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-07-08 16:48:59 +0200
committerKim Alvefur <zash@zash.se>2018-07-08 16:48:59 +0200
commit10cf2b24e6554da98a320842b700798dd58cb149 (patch)
tree7491ff1eae6c276d099760199e6a2103184fdb49 /util/stanza.lua
parent220816dc8a0eaaa8f41c4d86430ac468687f31f1 (diff)
downloadprosody-10cf2b24e6554da98a320842b700798dd58cb149.tar.gz
prosody-10cf2b24e6554da98a320842b700798dd58cb149.zip
util.stanza: Add method for removing all children with a specific name, xmlns
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index 2191fa8e..07365144 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -97,6 +97,16 @@ function stanza_mt:add_child(child)
return self;
end
+function stanza_mt:remove_children(name, xmlns)
+ xmlns = xmlns or self.attr.xmlns;
+ return self:maptags(function (tag)
+ if (not name or tag.name == name) and tag.attr.xmlns == xmlns then
+ return nil;
+ end
+ return tag;
+ end);
+end
+
function stanza_mt:get_child(name, xmlns)
for _, child in ipairs(self.tags) do
if (not name or child.name == name)