class REXML::Child

class directly.
contains methods to support that. Most user code will not use this
A Child object is something contained by a parent, and this class
#

def bytes

This doesn't yet handle encodings
def bytes
  document.encoding
  to_s
end

def document

belongs to no document
Returns:: the document this child belongs to, or nil if this child
def document
  return parent.document unless parent.nil?
  nil
end

def initialize( parent = nil )

supplied value, and self will be added to the parent
if supplied, the parent of this child will be set to the
parent::
sure this method is called.
Constructor. Any inheritors of this class should call super to make
def initialize( parent = nil )
  @parent = nil
  # Declare @parent, but don't define it.  The next line sets the
  # parent.
  parent.add( self ) if parent
end

def next_sibling=( other )

# =>
b.next_sibling = c
c = Element.new("c")
b = a.add_element("b")
a = Element.new("a")
after some other child.
Sets the next sibling of this child. This can be used to insert a child
def next_sibling=( other )
  parent.insert_after self, other
end

def parent=( other )

Returns:: The parent added
to the new parent.
child is removed from the current parent (if one exists), and is added
existing parent of this child, no action is taken. Otherwise, this
Must be a Parent object. If this object is the same object as the
other::

Sets the parent of this child to the supplied argument.
def parent=( other )
  return @parent if @parent == other
  @parent.delete self if defined? @parent and @parent
  @parent = other
end

def previous_sibling=(other)

# =>
b.previous_sibling = c
c = Element.new("c")
b = a.add_element("b")
a = Element.new("a")
child before some other child.
Sets the previous sibling of this child. This can be used to insert a
def previous_sibling=(other)
  parent.insert_before self, other
end

def remove

Returns:: self

Removes this child from the parent.
def remove
  unless @parent.nil?
    @parent.delete self
  end
  self
end

def replace_with( child )

Returns:: self

Parent.replace_child
Replaces this object with another object. Basically, calls
def replace_with( child )
  @parent.replace_child( self, child )
  self
end