mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 13:47:41 +03:00
util.stanza: Add method for removing all children with a specific name, xmlns
This commit is contained in:
parent
81da3564dc
commit
759fe72f49
1 changed files with 10 additions and 0 deletions
|
@ -97,6 +97,16 @@ function stanza_mt:add_child(child)
|
||||||
return self;
|
return self;
|
||||||
end
|
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)
|
function stanza_mt:get_child(name, xmlns)
|
||||||
for _, child in ipairs(self.tags) do
|
for _, child in ipairs(self.tags) do
|
||||||
if (not name or child.name == name)
|
if (not name or child.name == name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue