Links: Next Previous Up Top

# What do I do with an `SGMLS_Element`?

Altogether, there are six classes in `SGMLS.pm`, each with its own methods: in addition to `SGMLS` (for the parse) and `SGMLS_Event` (for a specific event), the classes are `SGMLS_Element`, `SGMLS_Attribute`, `SGMLS_Entity`, and `SGMLS_Notation`. Like all of these, `SGMLS_Element` has a number of methods available for obtaining different types of information. For example, if you were to use

    my $element = $event->data

to retrieve the data for a `'start_element'` or `'end_element'` event, then you could use the methods listed in table 3 to find more information about the element.

### Table 3: The `SGMLS_Element` class

Method
  `name`
Return Type
  string
Description
  The name (or GI), in upper-case.

Method
  `parent`
Return Type
  `SGMLS_Element`
Description
  The parent element, or `''` if this is the top element.

Method
  `attributes`
Return Type
  HASH
Description
  Return a reference to a hash table of `SGMLS_Attribute` objects, keyed by the attribute names (in upper-case).

Method
  `attribute_names`
Return Type
  ARRAY
Description
  A list of all attribute names for the current element (in upper-case).

Method
  `attribute(<IT>aname</IT>)`
Return Type
  `SGMLS_Attribute`
Description
  Return the attribute named ANAME.

Method
  `set_attribute(<IT>attribute</IT>)`
Return Type
  [none]
Description
  The <IT>attribute</IT> argument should be an object belonging to the `SGMLS_Attribute` class. Add it to the element, replacing any previous attribute with the same name.

Method
  `in(<IT>name</IT>)`
Return Type
  `SGMLS_Element`
Description
  If the current element's parent is named <IT>name</IT>, return the parent; otherwise, return `''`.

Method
  `within(<IT>name</IT>)`
Return Type
  `SGMLS_Element`
Description
  If any ancestor of the current element is named <IT>name</IT>, return it; otherwise, return `''`.

Links: Next Previous Up Top