- if (!started_) { started_ = true ; return true; }
- indent_ += ANNA_XML_INDENTATION_SPACES;
- if (last_was_start_) result_ << ">\n";
- last_was_start_ = true;
- if (!last_was_array_) nodes_stack_.push(key_);
- result_ << std::string(indent_, ' ') << "<" << nodes_stack_.top();
- if (last_was_array_) nodes_stack_.push(key_);
- last_was_array_ = false;
+ if (key_ == "") return true; // global object condition (first start object)
+ nodes_stack_.push(key_); // push on starts
+ indent_ += ANNA_XML_INDENTATION_SPACES; // increase indentation on object start
+
+ if (indent_ != 0) {
+ // New object when previous hadn't attributes:
+ if (current_object_.str().empty() && !has_attributes_) result_ <<">";
+ result_ << "\n";
+ }
+ result_ << std::string(indent_, ' ') << "<" << get_top();
+
+ has_attributes_ = false;