Changeset

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
parents 688:5f77bbc1f04a
children 690:e901a0709005
files util/stanza.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
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)