Module: Libxml4r::XML::Node

Included in:
LibXML::XML::Node
Defined in:
lib/libxml4r.rb

Defined Under Namespace

Classes: SearchNodes

Instance Method Summary collapse

Instance Method Details

#inner_htmlObject

:call-seq:

self.inner_html -> String

Alias for XML::Node.inner_xml



99
100
101
# File 'lib/libxml4r.rb', line 99

def inner_html
  self.inner_xml
end

#last=(node) ⇒ Object

:call-seq:

self.last = XML::Node -> XML::Node

Alias for XML::Node.sibling=



108
109
110
# File 'lib/libxml4r.rb', line 108

def last=(node)
  return self.sibling = node
end

#nodeObject

:call-seq:

self.node["/xpath"] -> XML::Node

Returns the first Node object matching “/xpath”, or nil if no object could not be found. The path searched is relative to the node from which node[] was called.

Note its usually recommended to remove all namespaces with strip! before xpath traversal.



120
121
122
# File 'lib/libxml4r.rb', line 120

def node()
  return SearchNodes.new(:node => self, :return_many => false)
end

#node_at(xpath) ⇒ Object

:nodoc:



124
125
126
# File 'lib/libxml4r.rb', line 124

def node_at(xpath) #:nodoc:
  self.find_first(xpath)
end

#nodesObject

:call-seq:

self.nodes["/xpath"] -> [XML::Node, XML::Node, XML::Node, ...]

Returns an array containing all nodes matching “/xpath”, or nil if no object could not be found. The path searched is relative to the node from which node[] was called.

Note its usually recommended to remove all namespaces with strip! before xpath traversal.



135
136
137
# File 'lib/libxml4r.rb', line 135

def nodes()
  return SearchNodes.new(:node => self, :return_many => true)
end

#nodes_at(xpath) ⇒ Object

:nodoc:



139
140
141
142
143
144
145
146
147
# File 'lib/libxml4r.rb', line 139

def nodes_at(xpath) #:nodoc:
  results = self.find(xpath).to_a
  if block_given?
    results.each do |result|
      yield result
    end
  end
  return results
end

#to_xmlObject

:call-seq:

self.to_xml -> String

Alias for XML::Node.to_s



193
194
195
# File 'lib/libxml4r.rb', line 193

def to_xml
  return self.to_s
end