rapidxml
manual-for-doxygen.hpp
1// This documentation is parsed by Doxygen to produce manual with working links to reference section
2
96using namespace rapidxml;
97xml_document<> doc; // character type defaults to char
98doc.parse<0>(text); // 0 means default parse flags
99\endverbatim
113cout << "Name of my first node is: " << doc.first_node()->name() << "\n";
114xml_node<> *node = doc.first_node("foobar");
115cout << "Node foobar has value " << node->value() << "\n";
116for (xml_attribute<> *attr = node->first_attribute();
117 attr; attr = attr->next_attribute())
118{
119 cout << "Node foobar has attribute " << attr->name() << " ";
120 cout << "with value " << attr->value() << "\n";
121}
122\endverbatim
129xml_document<> doc;
130xml_node<> *node = doc.allocate_node(node_element, "a", "Google");
131doc.append_node(node);
132xml_attribute<> *attr = doc.allocate_attribute("href", "google.com");
133node->append_attribute(attr);
134\endverbatim
143xml_document<> doc;
144char *node_name = doc.allocate_string(name); // Allocate string and copy name into it
145xml_node<> *node = doc.allocate_node(node_element, node_name); // Set node name to node_name
146\endverbatim
153using namespace rapidxml;
154xml_document<> doc; // character type defaults to char
155// ... some code to fill the document
156
157// Print to stream using operator <<
158std::cout << doc;
159
160// Print to stream using print function, specifying printing flags
161print(std::cout, doc, 0); // 0 means default printing flags
162
163// Print to string using output iterator
164std::string s;
165print(std::back_inserter(s), doc, 0);
166
167// Print to memory buffer using output iterator
168char buffer[4096]; // You are responsible for making the buffer large enough!
169char *end = print(buffer, doc, 0); // end contains pointer to character after last printed character
170*end = 0; // Add string terminator after XML
171\endverbatim
OutIt print(OutIt out, const xml_node< Ch > &node, int flags=0)
Definition rapidxml_print.hpp:388
Definition rapidxml.hpp:31