Class REXML::Elements
In: /home/ser/Work/rexml/rexml/element.rb
Parent: Object
Package diagram
A class which provides filtering of children for Elements, and XPath search support.
Methods
[]    []=    add    delete    delete_all    each    empty?    index    new    size    to_a   
Included modules
Enumerable
Public Class methods
new(parent)
Constructor @param parent the parent Element
Public Instance methods
[]( index, name=nil)
Fetches a child element @param index the search parameter. This is either an Integer, which will be used to find the index'th child Element, or an XPath, which will be used to search for the Element. NOTE that because of the nature of XPath searches, any element in the connected XML document can be fetched through any other element. @param name optional, and only used in the first argument is an Integer. In that case, the index'th child Element that has the supplied name will be returned. Note that the indexes start at 1. @return the first matching Element, or nil if no child matched
[]=( index, element )
Sets an element, replacing any previous matching element. If no existing element is found ,the element is added. @param index is used to find a matching element to replace. See [](). @param element the element to replace the existing element with @return the previous element; nil if no previous element was found.
empty?()
@return true if there are no Element children, false otherwise
index(element)
@return the index of the supplied child (starting at 1), or -1 if the element is not a child @param element a child of this Element
delete(element)
Deletes a child Element @param element Either an Element, which is removed directly; an xpath, where the first matching child is removed; or an Integer, where the n'th Element is removed. @return the removed child
delete_all( xpath )
Removes multiple elements @param xpath all elements matching this String path are removed. @return an Array of Elements that have been removed
add(element=nil)
Adds an element @param element if supplied, is either an Element, String, or Source (see Element.initialize). If not supplied or nil, a new, default Element will be constructed @return the added Element
each( xpath=nil, &block)
Iterates through all of the child Elements, optionally filtering them by a given XPath Only supply the first parameter (and a block). The second parameter is used internally for recursion. @param xpath optional. If supplied, this is a String XPath, and is used to filter the children, so that only matching children are yielded
size()
to_a( xpath=nil )