Riak's JS virtual machine doesn't have support for XML natively, but Erlang functions do via the standard library's "xmerl" application.
map_xpath(Object, _KeyData, XPath) ->
%% Get the value out of the riak object
{ok, Body} = riak_object:get_value(Object),
%% Parse the XML contents into data structures
{Doc, _} = xmerl_scan:string(unicode:characters_to_list(Body)),
%% Extract the fragment via XPath
xmerl_xpath:string(XPath, Doc).
This is pretty generic, you might want something more specific. Since the XPath query can, in some cases, return a scalar value instead of a list of nodes, one might want to wrap the return value in a list, or otherwise associate something with the query result and wrap that in a list (e.g. get the bucket/key off the object).