1
0
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:
Anton Todorov 2017-06-30 23:18:40 +03:00 committed by Javi Fontan
parent cb0b3fc0b4
commit 172548b4cd

View File

@ -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