class Elements

Includes Enumerable
A class which provides filtering of children for Elements, and XPath search support.

Methods


Aliases

<<

is a synonym for

add

Methods

[]

Arguments

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.
name<nil>
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.
Returns the first matching Element, or nil if no child matched
Fetches a child element

[]=

Arguments

index
is used to find a matching element to replace. See []().
element
the element to replace the existing element with
Returns the previous element; nil if no previous element was found.
Sets an element, replacing any previous matching element. If no existing element is found ,the element is added.

add

Arguments

element<nil>
if supplied, is either an Element, String, or Source (see Element.initialize). If not supplied or nil, a new, default Element will be constructed
Returns the added Element
Adds an element

delete

Arguments

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.
Returns the removed child
Deletes a child Element

delete_all

Arguments

xpath
all elements matching this String path are removed.
Returns an Array of Elements that have been removed
Removes multiple elements

each

Arguments

xpath<nil>
optional. If supplied, this is a String XPath, and is used to filter the children, so that only matching children are yielded
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.

empty

Returns true if there are no Element children, false otherwise

index

Arguments

element
a child of this Element
Returns the index of the supplied child (starting at 1), or -1 if the element is not a child
@return the index of the supplied child (starting at 1), or -1 if the element is not a child

initialize

Arguments

parent
the parent Element

Constructor

literalize

Arguments

name

A private helper method

size