1. A computer implemented method comprising: receiving a markup language document specifying a user interface for interacting with a user; receiving a specification comprising a mapping from sets of node types to sets of handlers, wherein each set of node types specified in the mapping is mapped to a set of handlers; representing the markup language document using a hierarchical structure of nodes representing elements of the markup language document and edges connecting the nodes, wherein the hierarchical structure comprises: a subset of nodes mapped to node types; and a root node connected with other nodes via paths comprising nodes and edges; receiving a user input associated with a selected node; identifying a set of node types encountered in a path connecting the root node with the selected node; identifying a set of handlers mapped to the identified set of node types based on the mapping; and executing the handlers in the identified set of handlers.