Feature #294
oca - XMLUtils, [] returning nil when the XML element has more levels inside.
Status: | Closed | Start date: | 07/23/2010 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | Daniel Molina | % Done: | 100% | |
Category: | Client API & Library | |||
Target version: | Release 2.0 | |||
Resolution: | fixed | Pull request: |
Description
[] operator is returning nil when the XML element has more levels inside.
A exists? or hash_element? method should be implemented for checking the existence of an element instead of getting a nil from the [][ operator.
if vm['TEMPLATE/DISK'] != nil
vm.each('TEMPLATE/DISK') do |disk|
Now you have to ignore the if
vm.each('TEMPLATE/DISK') do |disk|
because vm['TEMPLATE/DISK'] returns nil:
Solution:
if vm.hash_element?('TEMPLATE/DISK')
vm.each('TEMPLATE/DISK') do |disk|
History
#1 Updated by Ruben S. Montero almost 11 years ago
- Category set to Client API & Library
- Assignee set to Daniel Molina
- Target version set to Release 2.0
#2 Updated by Daniel Molina over 10 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
- Resolution set to fixed
Added a new method has_element?(xpath)