Skip to content

Commit

Permalink
M #-: Add --subtree to xpath.rb (#41)
Browse files Browse the repository at this point in the history
(cherry picked from commit b909275)
  • Loading branch information
xorel authored and rsmontero committed Jul 14, 2020
1 parent b72b19a commit 76ce056
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/datastore_mad/remotes/xpath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@

opts = opts = GetoptLong.new(
[ '--stdin', '-s', GetoptLong::NO_ARGUMENT ],
[ '--subtree', '-t', GetoptLong::NO_ARGUMENT ],
[ '--base64', '-b', GetoptLong::REQUIRED_ARGUMENT ]
)

source = :stdin
tmp64 = ""
subtree = false

begin
opts.each do |opt, arg|
case opt
when '--stdin'
source = :stdin
when '--subtree'
subtree = true
when '--base64'
source = :b64
tmp64 = arg
Expand Down Expand Up @@ -65,10 +69,10 @@
else
element = xml.elements[xpath.dup]
if !element.nil?
if element.class.method_defined?(:text)
values << ( element.text || '' )
else
if subtree
values << ( element.to_s || '' )
else
values << ( element.text || '' )
end
end
end
Expand Down

0 comments on commit 76ce056

Please sign in to comment.