#include #include using namespace std; #include "xml.hpp" class MyXML : public XML { public: explicit MyXML(ostream& out, size_t indent = 4) : pout_(&out) , depth_(0) , indent_(indent) { } protected: void handle_start(const string& name, const vector>& attr) { *pout_ << string(depth_++ * indent_, ' ') << "<" << name; auto it = cbegin(attr); auto end = cend(attr); if ( it != end ) { *pout_ << " " << it->first << "=\"" << it->second << "\""; ++it; // skip first Element for ( ; it != end; ++it ) *pout_ << ", " << it->first << "=\"" << it->second << "\""; } *pout_ << ">" << endl; } void handle_end(const string& name) { *pout_ << string(--depth_ * indent_, ' ') << "" << endl; } private: ostream* pout_; size_t depth_; size_t indent_; }; int main() { try { MyXML myxml(cout); myxml.parse(cin); } catch ( exception& e ) { cerr << "Fehler: " << e.what() << endl; } }