util/stanza.lua
changeset 11790 39164ea2ab9e
parent 11646 7f2dee4249aa
child 11964 12a3c05aa12d
equal deleted inserted replaced
11789:b1381e302cab 11790:39164ea2ab9e
   186 end
   186 end
   187 
   187 
   188 function stanza_mt:child_with_ns(ns)
   188 function stanza_mt:child_with_ns(ns)
   189 	for _, child in ipairs(self.tags) do
   189 	for _, child in ipairs(self.tags) do
   190 		if child.attr.xmlns == ns then return child; end
   190 		if child.attr.xmlns == ns then return child; end
       
   191 	end
       
   192 end
       
   193 
       
   194 function stanza_mt:get_child_with_attr(name, xmlns, attr_name, attr_value, normalize)
       
   195 	for tag in self:childtags(name, xmlns) do
       
   196 		if (normalize and normalize(tag.attr[attr_name]) or tag.attr[attr_name]) == attr_value then
       
   197 			return tag;
       
   198 		end
   191 	end
   199 	end
   192 end
   200 end
   193 
   201 
   194 function stanza_mt:children()
   202 function stanza_mt:children()
   195 	local i = 0;
   203 	local i = 0;