Ruby REXML::Element Functions

EditRocket provides the following information on REXML::Element functions in the Ruby source code builder.

add_attribute( key, value=nil ) - Adds an attribute to this element, overwriting any existing attribute by the same name.

add_attributes(hash) - Add multiple attributes to this element.

add_element(element, attrs=nil) - Adds a child to this element, optionally setting attributes in the element.

add_namespace( prefix, uri=nil ) - Adds a namespace to this element.

add_text( text ) - A helper method to add a Text child. Actual Text instances can be added with regular Parent methods, such as add() and <<()

attribute( name, namespace=nil ) - "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(key) - Removes an attribute

delete_element(element) - Deletes a child element.

delete_namespace(namespace="xmlns") - 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( xpath=nil ) - Synonym for Element.elements.each

each_element_with_attribute( key, value=nil, max=0, name=nil ) - Iterates through the child elements, yielding for each Element that has a particular attribute set.

each_element_with_text( text=nil, max=0, name=nil ) - Iterates through the children, yielding for each Element that has a particular text set.

get_elements( xpath ) - Synonym for Element.to_a This is a little slower than calling elements.each directly.

get_text(path = nil) - 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(prefix=nil) - 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( arg = UNDEFINED, parent=nil, context=nil ) - 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=( text ) - Sets the first Text child of this object. See text() for a discussion about Text children.

text( path = nil ) - A convenience method which returns the String value of the first child text element, if one exists, and nil otherwise.

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(writer=$stdout, indent=-1, transitive=false, ie_hack=false) - See REXML::Formatters

xpath() -