I have a child element called Request inside my message element of xmpp packet. Therefore, my packet looks like the below:
<message to="b" from="a" type="chat">
<request xmlns="urn:client:send-ack"></request>
</message>
I want to match the value of xmlns attribute inside the request element. So I want to do something like
case xml:get_attr_s(<<"xmlns">>, xml_get_subtag(<<Request>>,Packet)) of
"urn:client:send-receipts" ->
%% Do something
ok.
But, obviously this densest work. Whats the best way to do it ?
Easy and fast way to get this attribute is exml_query:path/2
. With it, your case ... of
would be following:
case exml_query:path(Stanza, [{element, <<"request">>}, {attr, <<"xmlns">>}]) of
<<"urn:client:send-receipts">> -> something;
_ -> something_else
end