I tested this, it's pretty basic but it's working fine, although I'm pretty sure is quite inefficient and/or there might be better ways for doing this (wait for the cavalry to arrive):
1> X = {xmlelement,"presence", [{"xml:lang","en"}, {"ver","6.00.00"}, {"to", "test@conference.localhost/user"}], [{xmlelement,"c", [{"xmlns", "http://jabber.org/protocol/caps"}, {"node", "http://www.google.com/xmpp/client/caps/"}, {"ver", "eVvrsq8jya/4AZMjFl5BeDKSmg4="}, {"hash","sha-1"}], []}, {xmlelement,"nick", [{"xmlns", "http://jabber.org/protocol/nick"}], [{xmlcdata,<<"user">>}]}, {xmlelement,"x", [{"xmlns", "http://jabber.org/protocol/muc"}], [{xmlelement,"history", [{"maxstanzas","20"}, {"maxchars","32768"}], []}]}]}.
{xmlelement,"presence",
[{"xml:lang","en"},
{"ver","6.00.00"},
{"to","test@conference.localhost/user"}],
[{xmlelement,"c",
[{"xmlns","http://jabber.org/protocol/caps"},
{"node","http://www.google.com/xmpp/client/caps/"},
{"ver","eVvrsq8jya/4AZMjFl5BeDKSmg4="},
{"hash","sha-1"}],
[]},
{xmlelement,"nick",
[{"xmlns","http://jabber.org/protocol/nick"}],
[{xmlcdata,<<"user">>}]},
{xmlelement,"x",
[{"xmlns","http://jabber.org/protocol/muc"}],
[{xmlelement,"history",
[{"maxstanzas","20"},
{"maxchars","32768"}],
[]}]}]}
2> {xmlelement,_,[{_,_},{_,_},{_,_}],[{xmlelement,_,[{_,_},{"node",Node},{_,_},{_,_}],[]},{xmlelement,_,[{_,_}],[{xmlcdata,_}]},{xmlelement,_,[{_,_}],[{xmlelement,_,[{_,_},{"maxchars",MaxChars}],[]}]}]} = X.
{xmlelement,"presence",
[{"xml:lang","en"},
{"ver","6.00.00"},
{"to","test@conference.localhost/user"}],
[{xmlelement,"c",
[{"xmlns","http://jabber.org/protocol/caps"},
{"node","http://www.google.com/xmpp/client/caps/"},
{"ver","eVvrsq8jya/4AZMjFl5BeDKSmg4="},
{"hash","sha-1"}],
[]},
{xmlelement,"nick",
[{"xmlns","http://jabber.org/protocol/nick"}],
[{xmlcdata,<<"user">>}]},
{xmlelement,"x",
[{"xmlns","http://jabber.org/protocol/muc"}],
[{xmlelement,"history",
[{"maxstanzas","20"},
{"maxchars","32768"}],
[]}]}]}
3> Node.
"http://www.google.com/xmpp/client/caps/"
4> MaxChars.
"32768"
5>
On line 2>
we pattern match the values that you are expecting in that "format". Place the bindings in the locations you want to get the values from and, if possible, establish some constraints like, for instance, the atoms that won't change in the XML packet. I hope you get the idea.