1 // Copyright (c) 2005 Carl Barron. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying file
3 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5 #include "xml_g.hpp"
6 #include <boost/spirit/include/classic_utility.hpp>
7 #include <iostream>
8
9 namespace std
10 {
operator <<(std::ostream & os,std::pair<std::string,std::string> const & p)11 std::ostream & operator << (std::ostream &os,std::pair<std::string,std::string> const &p)
12 {
13 return os << p.first << '=' << p.second;
14 }
15
operator <<(std::ostream & os,const tag & t)16 std::ostream & operator << (std::ostream &os,const tag &t)
17 {
18 return os << t.id;
19 }
20
21 }
22
main()23 int main()
24 {
25 const char *test =
26 // "<A x=\"1\" y=\"2\"> test 1 </A>"
27 // "<B x=\"3\" y= \"4\" z = \"10\"> test 3 </B>"
28 // "<C><A></A><V><W></W></V></C>"
29 // "<D x=\"4\"/>"
30 "<E>xxx<F>yyy</F>zzz</E>"
31 ;
32 std::list<tag> tags;
33 xml_g g(tags);
34
35 if(SP::parse(test,g,SP::comment_p("<---","--->")).full)
36 {
37 std::for_each(tags.begin(),tags.end(),walk_data());
38 }
39 else
40 {
41 std::cout << "parse failed\n";
42 }
43 }
44