name = $tag['tag']; $elements[$index]->attributes = $tag['attributes']; $elements[$index]->content = $tag['value']; if ($tag['type'] == "open") { // push $elements[$index]->children = array(); $stack[count($stack)] = &$elements; $elements = &$elements[$index]->children; } } if ($tag['type'] == "close") { // pop $elements = &$stack[count($stack) - 1]; unset($stack[count($stack) - 1]); } } return $elements[0]; // the single top-level element } ?>