'List (extract) user-fields with type and value.
field_names ... list of field names to show or None for all.
Returns list of tuples (<field name>, <field type>, <value>).'

def list_fields_and_values(self, field_names=None):

    self.loaddoc()
    found_fields = []
    all_fields = self.document.getElementsByType(UserFieldDecl)
    for f in all_fields:
        value_type = f.getAttribute('valuetype')
        if (value_type == 'string'):
            value = f.getAttribute('stringvalue')
        else:
            value = f.getAttribute('value')
        field_name = f.getAttribute('name')
        if ((field_names is None) or (field_name in field_names)):
            found_fields.append((field_name.encode(OUTENCODING), value_type.encode(OUTENCODING), value.encode(OUTENCODING)))
    return found_fields
