Xport Interface: element::attribute

Sets or retrieves an attribute value for the called element.

virtual std::string element::attribute(1st Variety
  xhtml_attribute attrib
);
virtual bool element::attribute(2nd Variety
  xhtml_attribute attrib,
  const std::string& value
);

Parameters

attrib

An xhtml_attribute enumerator. For a list of xhtml_attribute enumerators, see Xport Usage: Enumerations.

value

A string value which represents the value of the accompanied attribute.

Returns

In the first variety, returns the string value of the specified attribute if the attribute is present within the called element, or an empty string otherwise. In the second variety, returns true if the attribute is set successfully, false otherwise.

Remarks

This operation is used to set or retrieve an attribute value in the called element. When setting an element's attribute, Xport will only allow attributes to be set which are valid attributes for the called element. The attribute values are represented by strings. All attribute values will be properly delimeted by single or double quotes when writing the element or document, so there is no need to include the single or double quotes when specifying the attributes value. When retrieving attributes in the second variety obove, a string value is returned without the single/double quote delimiters.

The first variety above allows the retrieval of a single attribute value. If you wish to determine which attributes are present for a particular element, use the elment::attributes() operation, which returns a map of all attibutes present in the called element.

Complexity

Constant

Example

Work Time Studio

Datasoft Solutions is proud to present their landmark product, Work Time Studio. Utilizing the tree container library, Work Time Studio provides unparalleled features in personal time, project and task management software. If you're looking for a way to increase your productivity, visit Work Time Studio's product website, and start being more productive today.