Xport Interface: element::tag_name
Returns the tag name of the called element
.
std::string element::tag_name();
Parameters
None
Returns
Returns a string which specifies the tag name of the called element.
Remarks
This operation is used to retrieve the tag name of the called element
object.
Complexity
Constant
Example
#include "xhtml_doc.h"
#include <iostream>
void print_element(const Xport::markup& mkup, int depth);
int main(int argc, char* argv[])
{
using namespace Xport;
document doc(root_doc);
*doc.body() << (element(h1) << "Test document");
*doc.body() << (element(p) << "This is a test document generated by Xport.");
markup::iterator it = doc.body()->insert(element(ul));
*it << (element(li) << "List item 1");
*it << (element(li) << "List item 2");
*it << (element(li) << "List item 3");
print_element(*doc.html(), 0);
return 0;
}
void print_element(const Xport::markup& mkup, int depth)
{
using namespace Xport;
std::cout << std::string(depth, ' ') << mkup.tag_name() << "\n";
markup::const_iterator it = mkup.begin();
for (; it != mkup.end(); ++it) {
if (it->markup_type() == mt_element) {
print_element(*it, depth + 1);
}
}
}