Represents a tagged XML element. Elements are characterized by having children, attributes, and names, and can themselves be children.
Methods
- #
- C
- E
- H
- L
- N
- P
- R
- S
- T
Constants
NAMESPLIT | = | /^(?:(#{XMLTokens::NCNAME_STR}):)?(#{XMLTokens::NCNAME_STR})/u |
PARENTS | = | [ :element, :document, :doctype ] |
Class Public methods
new(node=nil)
Link
Create a new element.
# File lib/rexml/light/node.rb, line 20 def initialize node=nil @node = node if node.kind_of? String node = [ :text, node ] elsif node.nil? node = [ :document, nil, nil ] elsif node[0] == :start_element node[0] = :element elsif node[0] == :start_doctype node[0] = :doctype elsif node[0] == :start_document node[0] = :document end end
Instance Public methods
<<(element)
Link
Append a child to this element, optionally under a provided namespace. The namespace argument is ignored if the element argument is an Element object. Otherwise, the element argument is a string, the namespace (if provided) is the namespace the element is created in.
=~( path )
Link
[]( reference, ns=nil )
Link
# File lib/rexml/light/node.rb, line 85 def []( reference, ns=nil ) if reference.kind_of? String pfx = '' pfx = "#{prefix(ns)}:" if ns at(3)["#{pfx}#{reference}"] elsif reference.kind_of? Range _old_get( Range.new(4+reference.begin, reference.end, reference.exclude_end?) ) else _old_get( 4+reference ) end end
[]=( reference, ns, value=nil )
Link
Doesn't handle namespaces yet
# File lib/rexml/light/node.rb, line 102 def []=( reference, ns, value=nil ) if reference.kind_of? String value = ns unless value at( 3 )[reference] = value elsif reference.kind_of? Range _old_put( Range.new(3+reference.begin, reference.end, reference.exclude_end?), ns ) else if value _old_put( 4+reference, ns, value ) else _old_put( 4+reference, ns ) end end end
children()
Link
each()
Link
has_name?( name, namespace = '' )
Link
local_name()
Link
local_name=( name_str )
Link
name=( name_str, ns=nil )
Link
namespace( prefix=prefix() )
Link
namespace=( namespace )
Link
node_type()
Link
parent()
Link
parent=( node )
Link
prefix( namespace=nil )
Link
root()
Link
size()
Link
text=( foo )
Link