Ejabberd server receives packet like this:
{xmlel,<<"message">>,[{<<"from">>,<<"user1@localhost/resource">>},{<<"to">>,<<"user2@localhost">>},{<<"xml:lang">>,<<"en">>},{<<"id">>,<<"947yW-9">>}],[{xmlcdata,<<">">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"Helllo wassup!">>}]}]}
I want to fetch data from this packet.
Needed data : Type, If the body has a certain parameter, say {<<"xml:lang">>,<<"en">>}
I am doing the following operations:
{_XMLEL, TYPE, DETAILS , _BODY} = Packet
This provides me the type : <<"message">> or <<"iq">> or <<"presence">>.
To check if DETAILS has {<<"xml:lang">>,<<"en">>} I do this:
Has_Attribute=lists:member({<<"xml:lang">>,<<"en">>},DETAILS)
Is there any better way to do this?
I also need the to and from attributes from the packet.