Issue modifying subtags
stevenlivz opened this issue · comments
I am able to use append_subtags to add my custom XML elements+namespaces to a Stanza.
However, the set_subtag, remove_subtag and has_subtag only seem to work with xmpp_element types so I am unable to do anything more with my settings (when i try i get "terminated with reason: {'module could not be loaded',[{undefined,do_get_name....").
The doco says "all sub-elements of Stanza matching Tag (i.e. xmpp_element() or xmlel() elements with the same tag name and namespace as Tag)" but the signatures say differently... eg.
-spec remove_subtag(Stanza :: iq(), Tag :: xmpp_element()) -> iq();
Is this an oversight or should i be doing things differently?
The signature is correct: you can only provide a known xmpp_element()
as an argument. Then function will match all elements in sub_els
(both xmpp_element()
or xmlel()
) against this known element.
Ah ok. So when I use append_subtags, how can i remove or change what i have added? At the moment I can only keep adding duplicates of the element.
If the question is how to add xmlel()
and then remove it: there is no way to do this (without hacks). You should create a schema for you element, see #9
Thanks. I have a module for something else but never thought of it for adding a sub-tag. Will look at that. thx.