From 76ce0564c1e622e730ff85c10aac5b107f8f7483 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Wed, 24 Jun 2020 16:35:43 +0200 Subject: [PATCH] M #-: Add --subtree to xpath.rb (#41) (cherry picked from commit b9092758e268c8aacccba780ae15c8ae2f0254fa) --- src/datastore_mad/remotes/xpath.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/datastore_mad/remotes/xpath.rb b/src/datastore_mad/remotes/xpath.rb index 2b7b9b74f41..15baa61af7b 100755 --- a/src/datastore_mad/remotes/xpath.rb +++ b/src/datastore_mad/remotes/xpath.rb @@ -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 @@ -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