Module: FastXml::Common

Included in:
Doc, Node
Defined in:
lib/fastxml_lib.rb

Instance Method Summary collapse

Instance Method Details

#/(xpath) ⇒ Object



15
16
17
# File 'lib/fastxml_lib.rb', line 15

def /(xpath)
  self.search( "/#{xpath.to_s}" )
end

#at(xpath) ⇒ Object



19
20
21
22
23
# File 'lib/fastxml_lib.rb', line 19

def at(xpath)
  nodes = self.search( xpath )
  return nil unless nodes && nodes.length > 0
  nodes[0]
end

#children_of_type(type) ⇒ Object



7
8
9
# File 'lib/fastxml_lib.rb', line 7

def children_of_type(type)
  self.search( "//#{type}" )
end

#each_child(&blk) ⇒ Object



11
12
13
# File 'lib/fastxml_lib.rb', line 11

def each_child(&blk)
  self.children.each { |chld| yield chld }
end