For a derived element object, retrieves a reference to the first child markup object.
markup& markup::front();1st Variety
const markup& markup::front() const;2nd Variety
Parameters
None
Returns
For a derived element object, returns a reference to the first child markup object.
Remarks
This operation is revelant only if it is called on an element derived object. The behavior is undefined if called on a pcdata,
comment, or procinstr object, or if called on an element object which has no children. Caller is responsible to
insure this operation is called on only element derived objects which have children.
Complexity
Constant
Example
1st Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
// create an xhtml strict root document and stylesheet
document doc(root_doc);
// add an unordered list to body, with 3 elements
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");
// get a reference to the first list item
markup& last = it->front();
last.style(css::color, "red");
// output document
formatter fmtr(std::cout);
doc.write(fmtr);
return 0;
}
2nd Variety
#include "xhtml_doc.h"
#include "xport_brochure.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
// create an xhtml strict root document and stylesheet
document doc(root_doc);
stylesheet ss;
xport_brochure broch;
broch.create(doc, ss);
// use a descendant iterator to find the first unordered list
markup::const_descendant_iterator it = doc.body()->descendant_begin();
for (; it != doc.body()->descendant_end(); ++it) {
if (it->tag() == ul) {
// found first unordered list
const markup& last_item = it->front();
if (!last_item.empty()) {
std::cout << "First item of the first user list: ";
formatter fmtr(std::cout);
last_item.begin()->write(fmtr);
std::cout << std::endl;
break;
}
}
}
return 0;
}
Datasoft Solutions is proud to present their landmark product, Work Time Studio. Utilizing the tree container library, Work Time Studio provides
unparalleled features in personal time, project and task management
software. If you're looking for a way to increase your productivity,
visit Work Time Studio's product website, and start being more productive
today.