Class: DiffXML::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/diffXML/utils.rb

Class Method Summary collapse

Class Method Details

.collectXPaths(doc, xpArray) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/diffXML/utils.rb', line 5

def self.collectXPaths(doc, xpArray)
  doc.element_children.each do |child|
    if child.element_children.empty?
      xpArray.push(getPath(child,child.name)) unless child.content.empty?
    else
      collectXPaths(child, xpArray)
    end
  end
end

.getPath(node, path = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/diffXML/utils.rb', line 15

def self.getPath(node, path = nil)
  if node.parent.name.eql? 'document'
    return path
  else
    if path.nil?
      getPath(node, node.name)
    else
      getPath(node.parent, "#{node.parent.name}/#{path}")
    end
  end
end