1. A computer implemented method for executing event handlers specified in a markup language document in a web browser, the method comprising: receiving a markup language document specifying a user interface for interacting with a user; 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 mapping from sets of node types to sets of handler functions; 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; and executing the handlers in the identified set of handlers.