Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
688:5f77bbc1f04a | 689:94b043fbaf33 |
---|---|
85 (self.last_add[#self.last_add] or self):add_direct_child(child); | 85 (self.last_add[#self.last_add] or self):add_direct_child(child); |
86 return self; | 86 return self; |
87 end | 87 end |
88 | 88 |
89 function stanza_mt:child_with_name(name) | 89 function stanza_mt:child_with_name(name) |
90 for _, child in ipairs(self) do | 90 for _, child in ipairs(self.tags) do |
91 if child.name == name then return child; end | 91 if child.name == name then return child; end |
92 end | |
93 end | |
94 | |
95 function stanza_mt:child_with_ns(ns) | |
96 for _, child in ipairs(self.tags) do | |
97 if child.attr.xmlns == ns then return child; end | |
92 end | 98 end |
93 end | 99 end |
94 | 100 |
95 function stanza_mt:children() | 101 function stanza_mt:children() |
96 local i = 0; | 102 local i = 0; |