本文整理汇总了C++中HtmlElement::GetChildByTag方法的典型用法代码示例。如果您正苦于以下问题:C++ HtmlElement::GetChildByTag方法的具体用法?C++ HtmlElement::GetChildByTag怎么用?C++ HtmlElement::GetChildByTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlElement
的用法示例。
在下文中一共展示了HtmlElement::GetChildByTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WalkChmTocOrIndex
static void WalkChmTocOrIndex(EbookTocVisitor *visitor, HtmlElement *list, UINT cp, bool isIndex, int level=1)
{
CrashIf(Tag_Ul != list->tag);
// some broken ToCs wrap every <li> into its own <ul>
for (; list && Tag_Ul == list->tag; list = list->next) {
for (HtmlElement *el = list->down; el; el = el->next) {
if (Tag_Li != el->tag)
continue; // ignore unexpected elements
bool valid;
HtmlElement *elObj = el->GetChildByTag(Tag_Object);
if (!elObj)
valid = false;
else if (isIndex)
valid = VisitChmIndexItem(visitor, elObj, cp, level);
else
valid = VisitChmTocItem(visitor, elObj, cp, level);
if (!valid)
continue; // skip incomplete elements and all their children
HtmlElement *nested = el->GetChildByTag(Tag_Ul);
// some broken ToCs have the <ul> follow right *after* a <li>
if (!nested && el->next && Tag_Ul == el->next->tag)
nested = el->next;
if (nested)
WalkChmTocOrIndex(visitor, nested, cp, isIndex, level + 1);
}
}
}
示例2: utassert
static void HtmlParser06()
{
HtmlParser p;
HtmlElement *root = p.Parse("<ul><p>ignore<li><br><meta><li><ol><li></ul><dropme>");
utassert(9 == p.ElementsCount());
utassert(0 == p.TotalAttrCount());
utassert(root->NameIs("ul"));
utassert(!root->next);
HtmlElement *el = root->GetChildByTag(Tag_Li);
utassert(el);
utassert(el->down->NameIs("br"));
utassert(el->down->next->NameIs("meta"));
utassert(!el->down->next->next);
el = root->GetChildByTag(Tag_Li, 1);
utassert(el);
utassert(!el->next);
el = el->GetChildByTag(Tag_Ol);
utassert(!el->next);
utassert(el->down->NameIs("li"));
utassert(!el->down->down);
}