Diff

util/stanza.lua @ 689:94b043fbaf33

Add child_with_ns() method to stanza elements, and fix child_with_name() to iterate tags rather than all children
author Matthew Wild <mwild1@gmail.com>
date Sun, 11 Jan 2009 06:27:57 +0000
parent 680:734994b61907
child 758:b1885732e979
line wrap: on
line diff
--- a/util/stanza.lua	Fri Jan 09 19:19:06 2009 +0000
+++ b/util/stanza.lua	Sun Jan 11 06:27:57 2009 +0000
@@ -87,11 +87,17 @@
 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)