mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
xpath.rb fix crash when querying empty-element tag
by returning empty string. Handling both `<test/>` and `<test></test>` test pattern: ``` echo -e "<A>\n<B>b</B>\n<C/>\n<D></D><E>e</E></A>\n"| /var/lib/one/remotes/datastore/xpath.rb /A/B /A/C /A/D /A/E | while IFS= read -r -d '' e; do echo "'$e'"; done ```
This commit is contained in:
parent
ae853eaebc
commit
ef25a75478
@ -66,9 +66,9 @@ ARGV.each do |xpath|
|
||||
element = xml.elements[xpath.dup]
|
||||
if !element.nil?
|
||||
if element.class.method_defined?(:text)
|
||||
values << element.text
|
||||
values << ( element.text || '' )
|
||||
else
|
||||
values << element.to_s
|
||||
values << ( element.to_s || '' )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user