Sha256: eaac72268c9b64d21d030f9fae5cf057452d3314dfa097570020b0e330c8a6d3
Contents?: true
Size: 619 Bytes
Versions: 60
Compression:
Stored size: 619 Bytes
Contents
module Relaton module ElementFinder attr_reader :document def find_text(xpath, element = nil) find(xpath, element)&.text end def find(xpath, element = nil) (element || document).at(apply_namespace(xpath)) end def find_xpath(xpath, element = nil) element&.xpath(apply_namespace(xpath)) end 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 end end
Version data entries
60 entries across 59 versions & 2 rubygems