GLib.markup_collect_attributes
Description: Reference for GLib.markup_collect_attributes

### Function

# GLibmarkup_collect_attributes

since: 2.16

#### Declaration [src]

    gboolean
    g_markup_collect_attributes (
      const gchar* element_name,
      const gchar** attribute_names,
      const gchar** attribute_values,
      GError** error,
      GMarkupCollectType first_type,
      const gchar* first_attr,
      ...
    )

#### Description [src]

Collects the attributes of the element from the data passed to the `GMarkupParser` start_element function, dealing with common error conditions and supporting boolean values.

This utility function is not required to write a parser but can save a lot of typing.

The `element_name`, `attribute_names`, `attribute_values` and `error` parameters passed to the start_element callback should be passed unmodified to this function.

Following these arguments is a list of “supported” attributes to collect. It is an error to specify multiple attributes with the same name. If any attribute not in the list appears in the `attribute_names` array then an unknown attribute error will result.

The `GMarkupCollectType` field allows specifying the type of collection to perform and if a given attribute must appear or is optional.

The attribute name is simply the name of the attribute to collect.

The pointer should be of the appropriate type (see the descriptions under `GMarkupCollectType`) and may be `NULL` in case a particular attribute is to be allowed but ignored.

This function deals with issuing errors for missing attributes (of type `G_MARKUP_ERROR_MISSING_ATTRIBUTE`), unknown attributes (of type `G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE`) and duplicate attributes (of type `G_MARKUP_ERROR_INVALID_CONTENT`) as well as parse errors for boolean-valued attributes (again of type `G_MARKUP_ERROR_INVALID_CONTENT`). In all of these cases `FALSE` will be returned and `error` will be set as appropriate.

Available since: 2.16

This function is not directly available to language bindings.

#### Parameters

`element_name`

  Type: `const gchar*`

  The current tag name.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`attribute_names`

  Type: `const gchar**`

  The attribute names.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`attribute_values`

  Type: `const gchar**`

  The attribute values.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`error`

  Type: `GError`

  A pointer to a `GError` or `NULL`.

  The data is owned by the caller of the function.

`first_type`

  Type: `GMarkupCollectType`

  The `GMarkupCollectType` of the first attribute.

`first_attr`

  Type: `const gchar*`

  The name of the first attribute.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`...`

  Type: ``

  A pointer to the storage location of the first attribute (or `NULL`), followed by more types names and pointers, ending with `G_MARKUP_COLLECT_INVALID`.

#### Return value

Type: `gboolean`

`TRUE` if successful.