Module: Libxml4r::XML::Node
- Included in:
- LibXML::XML::Node
- Defined in:
- lib/libxml4r.rb
Defined Under Namespace
Classes: SearchNodes
Instance Method Summary collapse
-
#inner_html ⇒ Object
:call-seq: self.inner_html -> String.
-
#last=(node) ⇒ Object
:call-seq: self.last = XML::Node -> XML::Node.
-
#node ⇒ Object
:call-seq: self.node -> XML::Node.
-
#node_at(xpath) ⇒ Object
:nodoc:.
-
#nodes ⇒ Object
:call-seq: self.nodes -> [XML::Node, XML::Node, XML::Node, …].
-
#nodes_at(xpath) ⇒ Object
:nodoc:.
-
#to_xml ⇒ Object
:call-seq: self.to_xml -> String.
Instance Method Details
#inner_html ⇒ Object
99 100 101 |
# File 'lib/libxml4r.rb', line 99 def inner_html self.inner_xml end |
#last=(node) ⇒ Object
108 109 110 |
# File 'lib/libxml4r.rb', line 108 def last=(node) return self.sibling = node end |
#node ⇒ Object
: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 |
#nodes ⇒ Object
: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_xml ⇒ Object
193 194 195 |
# File 'lib/libxml4r.rb', line 193 def to_xml return self.to_s end |