maik / xml-simple

Easy API for working with XML documents
MIT License
88 stars 27 forks source link

suppressempty does not suppress empty nodes if parent has attributes #26

Open yaauie opened 5 years ago

yaauie commented 5 years ago

If we are iterating over the children of an element, the suppressempty option should do so if the child has no attributes.

       element.each_element { |child|
         value = collapse(child)
-         if empty(value) && (element.attributes.empty? || @options['noattr'])
+         if empty(value) && (child.attributes.empty? || @options['noattr'])
           next if @options.has_key?('suppressempty') && @options['suppressempty'] == true
         end
         result = merge(result, child.name, value)
       }