Sha256: c7cb360f56e1828342e7ac76935b6c2978d872408c30dd21320fe916a03e5b6c
Contents?: true
Size: 619 Bytes
Versions: 43
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
43 entries across 43 versions & 1 rubygems