Add child_with_ns() method to stanza elements, and fix child_with_name() to iterate...
authorMatthew Wild <mwild1@gmail.com>
Sun, 11 Jan 2009 06:27:57 +0000 (06:27 +0000)
committerMatthew Wild <mwild1@gmail.com>
Sun, 11 Jan 2009 06:27:57 +0000 (06:27 +0000)
util/stanza.lua

index c4cecb6f9e36984af4e98c093acb04ab0d29ea9c..14a8f395774530aa918d14ca220021db8c03199a 100644 (file)
@@ -87,11 +87,17 @@ function stanza_mt:add_child(child)
 end
 
 function stanza_mt:child_with_name(name)
-       for _, child in ipairs(self) do 
+       for _, child in ipairs(self.tags) do    
                if child.name == name then return child; end
        end
 end
 
+function stanza_mt:child_with_ns(ns)
+       for _, child in ipairs(self.tags) do    
+               if child.attr.xmlns == ns then return child; end
+       end
+end
+
 function stanza_mt:children()
        local i = 0;
        return function (a)