rapidxml
manual-for-doxygen.hpp
00001 // This documentation is parsed by Doxygen to produce manual with working links to reference section
00002 
00096 using namespace rapidxml;
00097 xml_document<> doc;    // character type defaults to char
00098 doc.parse<0>(text);    // 0 means default parse flags
00099 \endverbatim
00113 cout << "Name of my first node is: " << doc.first_node()->name() << "\n";
00114 xml_node<> *node = doc.first_node("foobar");
00115 cout << "Node foobar has value " << node->value() << "\n";
00116 for (xml_attribute<> *attr = node->first_attribute();
00117      attr; attr = attr->next_attribute())
00118 {
00119     cout << "Node foobar has attribute " << attr->name() << " ";
00120     cout << "with value " << attr->value() << "\n";
00121 }
00122 \endverbatim
00129 xml_document<> doc;
00130 xml_node<> *node = doc.allocate_node(node_element, "a", "Google");
00131 doc.append_node(node);
00132 xml_attribute<> *attr = doc.allocate_attribute("href", "google.com");
00133 node->append_attribute(attr);
00134 \endverbatim
00143 xml_document<> doc;
00144 char *node_name = doc.allocate_string(name);        // Allocate string and copy name into it
00145 xml_node<> *node = doc.allocate_node(node_element, node_name);  // Set node name to node_name
00146 \endverbatim
00153 using namespace rapidxml;
00154 xml_document<> doc;    // character type defaults to char
00155 // ... some code to fill the document
00156 
00157 // Print to stream using operator <<
00158 std::cout << doc;   
00159 
00160 // Print to stream using print function, specifying printing flags
00161 print(std::cout, doc, 0);   // 0 means default printing flags
00162 
00163 // Print to string using output iterator
00164 std::string s;
00165 print(std::back_inserter(s), doc, 0);
00166 
00167 // Print to memory buffer using output iterator
00168 char buffer[4096];                      // You are responsible for making the buffer large enough!
00169 char *end = print(buffer, doc, 0);      // end contains pointer to character after last printed character
00170 *end = 0;                               // Add string terminator after XML
00171 \endverbatim