module Relaton::ElementFinder
Attributes
document[R]
Public Instance Methods
apply_namespace(xpath)
click to toggle source
# File lib/relaton/element_finder.rb, line 17 def apply_namespace(xpath) xpath .gsub(%r{/([a-zA-Z])}, "/xmlns:\\1") .gsub(%r{::([a-zA-Z])}, "::xmlns:\\1") .gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1") .gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1") end
find(xpath, element = nil)
click to toggle source
# File lib/relaton/element_finder.rb, line 9 def find(xpath, element = nil) (element || document).at(apply_namespace(xpath)) end
find_text(xpath, element = nil)
click to toggle source
# File lib/relaton/element_finder.rb, line 5 def find_text(xpath, element = nil) find(xpath, element)&.text end
find_xpath(xpath, element = nil)
click to toggle source
# File lib/relaton/element_finder.rb, line 13 def find_xpath(xpath, element = nil) element&.xpath(apply_namespace(xpath)) end