Class

Element

Extends:

Includes:

Represents a tagged XML element. Elements are characterized by having children, attributes, and names, and can themselves be children.

Constants
UNDEFINED
Public Attributes
attributes Mechanisms for accessing attributes and child elements of this element.
context The context holds information about the processing environment, such as whitespace handling.
elements Mechanisms for accessing attributes and child elements of this element.
Public Methods
add_attribute Adds an attribute to this element, overwriting any existing attribute by the same name.
add_attributes Add multiple attributes to this element.
add_element Adds a child to this element, optionally setting attributes in the element.
add_namespace Adds a namespace to this element.
add_text A helper method to add a Text child. Actual Text instances can be added with regular Parent methods, such as add() and <<()
attribute Attributes #
cdatas Get an array of all CData children. IMMUTABLE
clone Creates a shallow copy of self.
comments Get an array of all Comment children. IMMUTABLE
delete_attribute Removes an attribute
delete_element Deletes a child element.
delete_namespace Removes a namespace from this node. This only works if the namespace is actually declared in this node. If no argument is passed, deletes the default namespace.
document Evaluates to the document to which this element belongs, or nil if this element doesn’t belong to a document.
each_element Synonym for Element.elements.each
each_element_with_attribute Iterates through the child elements, yielding for each Element that has a particular attribute set.
each_element_with_text Iterates through the children, yielding for each Element that has a particular text set.
get_elements Synonym for Element.to_a This is a little slower than calling elements.each directly.
get_text Returns the first child Text node, if any, or nil otherwise. This method returns the actual Text node, rather than the String content.
has_attributes? Evaluates to true if this element has any attributes set, false otherwise.
has_elements? Evaluates to true if this element has at least one child Element
has_text? Evaluates to true if this element has at least one Text child
ignore_whitespace_nodes
inspect
instructions Get an array of all Instruction children. IMMUTABLE
namespace Evalutas to the URI for a prefix, or the empty string if no such namespace is declared for this element. Evaluates recursively for ancestors. Returns the default namespace, if there is one.
namespaces
new Constructor
next_element Returns the next sibling that is an element, or nil if there is no Element sibling after this one
node_type
prefixes Evaluates to an Array containing the prefixes (names) of all defined namespaces at this context node.
previous_element Returns the previous sibling that is an element, or nil if there is no Element sibling prior to this one
raw Evaluates to true if raw mode is set for this element. This is the case if the context has :raw set to :all or an array containing the name of this element.
root
root_node Evaluates to the root node of the document that this element belongs to. If this element doesn’t belong to a document, but does belong to another Element, the parent’s root will be returned, until the earliest ancestor is found.
text A convenience method which returns the String value of the first child text element, if one exists, and nil otherwise.
text= Sets the first Text child of this object. See text() for a discussion about Text children.
texts Get an array of all Text children. IMMUTABLE
whitespace Evaluates to true if whitespace is respected for this element. This is the case if:
write See REXML::Formatters
xpath
Private Methods
__to_xpath_helper
each_with_something A private helper method
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.