tidy_parser.php
private function walkForm($node, $form, $enclosing_label = '')
    {
        if ($node->name === 'a') {
            $this->page->addLink($this->tags()->createTag($node->name, (array) $node->attribute)
                                              ->addContent($this->innerHtml($node)));
        } elseif (in_array($node->name, array('input', 'button', 'textarea', 'select'))) {
            $this->addWidgetToForm($node, $form, $enclosing_label);
        } elseif ($node->name === 'label') {
            $this->labels[] = $this->tags()->createTag($node->name, (array) $node->attribute)
                                           ->addContent($this->innerHtml($node));
            if ($node->hasChildren()) {
                foreach ($node->child as $child) {
                    $this->walkForm($child, $form, SimplePage::normalise($this->innerHtml($node)));
                }
            }
        } elseif ($node->hasChildren()) {
            foreach ($node->child as $child) {
                $this->walkForm($child, $form);
            }
        }

        return $form;
    }
private function walkForm($node, $form, $enclosing_label = '')
    {
        if ($node->name === 'a') {
            $this->page->addLink($this->tags()->createTag($node->name, (array) $node->attribute)
                                              ->addContent($this->innerHtml($node)));
        } elseif (in_array($node->name, array('input', 'button', 'textarea', 'select'))) {
            $this->addWidgetToForm($node, $form, $enclosing_label);
        } elseif ($node->name === 'label') {
            $this->labels[] = $this->tags()->createTag($node->name, (array) $node->attribute)
                                           ->addContent($this->innerHtml($node));
            if ($node->hasChildren()) {
                foreach ($node->child as $child) {
                    $this->walkForm($child, $form, SimplePage::normalise($this->innerHtml($node)));
                }
            }
        } elseif ($node->hasChildren()) {
            foreach ($node->child as $child) {
                $this->walkForm($child, $form);
            }
        }

        return $form;
    }
Visits the given node and all children

@param object $node      Tidy XML node.