[ Version ( since = "2.16" ) ]
[ CCode ( sentinel = "G_MARKUP_COLLECT_INVALID" ) ]
public bool collect_attributes (string element_name, string[] attribute_names, string[] attribute_values, ...) throws MarkupError

Collects the attributes of the element from the data passed to the MarkupParser 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 throws 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 CollectType 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 CollectType) 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 throws will be set as appropriate.



the current tag name


the attribute names


the attribute values


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


a pointer to a Error or null


the name of the first attribute


the CollectType of the first attribute


true if successful

Namespace: GLib.Markup
Package: glib-2.0