protected function writeFields($fp, $fields)
    {
        foreach ($fields as $key => $value) {
            if (is_array($value)) {
                fwrite($fp, "<field name=\"$key\">\n");
                $this->writeFields($fp, $value);
                fwrite($fp, "</field>\n");
            } else {
                fwrite($fp, "<field name=\"$key\">\n<value>$value</value>\n</field>\n");
            }
        }
    }