5 * Copyright (C) 2002 The libxml++ development team
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <glibmm/convert.h> //For Glib::ConvertError
27 MySaxParser::MySaxParser()
32 MySaxParser::~MySaxParser()
36 void MySaxParser::on_start_document()
38 std::cout << "on_start_document()" << std::endl;
41 void MySaxParser::on_end_document()
43 std::cout << "on_end_document()" << std::endl;
46 void MySaxParser::on_start_element(const Glib::ustring& name,
47 const AttributeList& attributes)
49 std::cout << "node name=" << name << std::endl;
52 for(xmlpp::SaxParser::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
56 std::cout << " Attribute name=" << iter->name << std::endl;
58 catch(const Glib::ConvertError& ex)
60 std::cerr << "MySaxParser::on_start_element(): Exception caught while converting name for std::cout: " << ex.what() << std::endl;
65 std::cout << " , value= " << iter->value << std::endl;
67 catch(const Glib::ConvertError& ex)
69 std::cerr << "MySaxParser::on_start_element(): Exception caught while converting value for std::cout: " << ex.what() << std::endl;
74 void MySaxParser::on_end_element(const Glib::ustring& /* name */)
76 std::cout << "on_end_element()" << std::endl;
79 void MySaxParser::on_characters(const Glib::ustring& text)
83 std::cout << "on_characters(): " << text << std::endl;
85 catch(const Glib::ConvertError& ex)
87 std::cerr << "MySaxParser::on_characters(): Exception caught while converting text for std::cout: " << ex.what() << std::endl;
91 void MySaxParser::on_comment(const Glib::ustring& text)
95 std::cout << "on_comment(): " << text << std::endl;
97 catch(const Glib::ConvertError& ex)
99 std::cerr << "MySaxParser::on_comment(): Exception caught while converting text for std::cout: " << ex.what() << std::endl;
103 void MySaxParser::on_warning(const Glib::ustring& text)
107 std::cout << "on_warning(): " << text << std::endl;
109 catch(const Glib::ConvertError& ex)
111 std::cerr << "MySaxParser::on_warning(): Exception caught while converting text for std::cout: " << ex.what() << std::endl;
115 void MySaxParser::on_error(const Glib::ustring& text)
119 std::cout << "on_error(): " << text << std::endl;
121 catch(const Glib::ConvertError& ex)
123 std::cerr << "MySaxParser::on_error(): Exception caught while converting text for std::cout: " << ex.what() << std::endl;
127 void MySaxParser::on_fatal_error(const Glib::ustring& text)
131 std::cout << "on_fatal_error(): " << text << std::endl;
133 catch(const Glib::ConvertError& ex)
135 std::cerr << "MySaxParser::on_characters(): Exception caught while converting value for std::cout: " << ex.what() << std::endl;