-
DebXWoody
Hi. If I get a <message/> and I will check what's the message. Should I check the <name> of the child or shall I check the ns of the child?
-
Ge0rG
an XML element is uniquely identified by the combination of namespace and tag name
-
DebXWoody
libstrophe provides two functions 'xmpp_stanza_get_child_by_ns' and 'xmpp_stanza_get_child_by_name'.
-
DebXWoody
Ge0rG, I see, thanks!
-
MattJ
Yes, any sensible API should let you combine both
-
lovetox
yeah that api makes no sense
-
Ge0rG
DebXWoody: there are implementations that only use the tag name, because *often* tag names are globally unique. And then you can get very far until horrible things start to happen in silent and hideous ways
-
DebXWoody
The api also provides this kind of message: xmpp_handler_add (xmpp_conn_t *const conn, xmpp_handler handler, const char *const ns, const char *const name, const char *const type, void *const userdata). But I try to understand.
-
lovetox
also child? there can be children of "nam"✎ -
lovetox
also child? there can be children of "name" ✏
-
lovetox
does it return a list?
-
Zash
Also keep in mind that there's not a single child, each stanza (as well as any xml element) may have 0 or more child nodes (modulo schema etc)
-
DebXWoody
lovetox, Looks like just the first element.
-
Ge0rG
I think it would be a clean approach to define a handler for a certain namespace, and that handler would get passed all tags with that namespace
-
Zash
iterators are also nice
-
DebXWoody
Now, I see! This may the reason why the implementation in profanity looks little bit complex. Calling a handler is just based on the first xml element. If the handler has to check what's the stanza about, it should check for something like 'list of stanza' get_stanza(name, ns).