A method is provided for processing tree like data structures in a streaming manner. An initial context of name/value bindings is set up. A tree of objects is constructed. Each element in the tree of objects is represented as a function object that accepts a context parameter and a target parameter that it can send a stream of start, content, and end events to represent tree output. The parse tree of objects is examined for element names that are recognized as commands. The commands are converted to special function objects that implement command's semantics. Other elements, that are not recognized as commands, are mapped to a default function object.