当前位置: 首页>>代码示例>>C++>>正文


C++ HtmlElement::NameIs方法代码示例

本文整理汇总了C++中HtmlElement::NameIs方法的典型用法代码示例。如果您正苦于以下问题:C++ HtmlElement::NameIs方法的具体用法?C++ HtmlElement::NameIs怎么用?C++ HtmlElement::NameIs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlElement的用法示例。


在下文中一共展示了HtmlElement::NameIs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: utassert

static void HtmlParser02()
{
    HtmlParser p;
    HtmlElement *root = p.Parse("<a><b/><c></c  ><d at1=\"&lt;quo&amp;ted&gt;\" at2='also quoted'   att3=notquoted att4=&#101;&#x6e;d/></a>");
    utassert(4 == p.ElementsCount());
    utassert(4 == p.TotalAttrCount());
    utassert(root->NameIs("a"));
    utassert(NULL == root->next);
    HtmlElement *el = root->down;
    utassert(el->NameIs("b"));
    utassert(root == el->up);
    el = el->next;
    utassert(el->NameIs("c"));
    utassert(root == el->up);
    el = el->next;
    utassert(el->NameIs("d"));
    utassert(NULL == el->next);
    utassert(root == el->up);
    ScopedMem<WCHAR> val(el->GetAttribute("at1"));
    utassert(str::Eq(val, L"<quo&ted>"));
    val.Set(el->GetAttribute("at2"));
    utassert(str::Eq(val, L"also quoted"));
    val.Set(el->GetAttribute("att3"));
    utassert(str::Eq(val, L"notquoted"));
    val.Set(el->GetAttribute("att4"));
    utassert(str::Eq(val, L"end"));
}
开发者ID:eminemence,项目名称:advancedoptionsui-sumatrapdf,代码行数:27,代码来源:TrivialHtmlParser_ut.cpp

示例2:

HtmlElement *HtmlParser::FindParent(char *tagName)
{
    if (str::Eq(tagName, "li")) {
        // make a list item the child of the closest list
        for (HtmlElement *el = currElement; el; el = el->up) {
            if (el->NameIs("ul") || el->NameIs("ol"))
                return el;
        }
    }

    return currElement;
}
开发者ID:mercutiodesign,项目名称:sumatrapdf,代码行数:12,代码来源:TrivialHtmlParser.cpp

示例3: while

HtmlElement *HtmlParser::FindElementByNameNS(const char *name, const char *ns, HtmlElement *from)
{
    HtmlElement *el = from ? from : rootElement;
    if (from)
        goto FindNext;
    if (!el)
        return NULL;
CheckNext:
    if (el->NameIs(name) || ns && el->NameIsNS(name, ns))
        return el;
FindNext:
    if (el->down) {
        el = el->down;
        goto CheckNext;
    }
    if (el->next) {
        el = el->next;
        goto CheckNext;
    }
    // backup in the tree
    HtmlElement *parent = el->up;
    while (parent) {
        if (parent->next) {
            el = parent->next;
            goto CheckNext;
        }
        parent = parent->up;
    }
    return NULL;
}
开发者ID:mercutiodesign,项目名称:sumatrapdf,代码行数:30,代码来源:TrivialHtmlParser.cpp

示例4: HtmlParserFile

static void HtmlParserFile()
{
    WCHAR *fileName = L"HtmlParseTest00.html";
    // We assume we're being run from obj-[dbg|rel], so the test
    // files are in ..\src\utils directory relative to exe's dir
    ScopedMem<WCHAR> exePath(GetExePath());
    const WCHAR *exeDir = path::GetBaseName(exePath);
    ScopedMem<WCHAR> p1(path::Join(exeDir, L"..\\src\\utils"));
    ScopedMem<WCHAR> p2(path::Join(p1, fileName));
    char *d = file::ReadAll(p2, NULL);
    // it's ok if we fail - we assume we were not run from the
    // right location
    if (!d)
        return;
    HtmlParser p;
    HtmlElement *root = p.ParseInPlace(d);
    utassert(root);
    utassert(709 == p.ElementsCount());
    utassert(955 == p.TotalAttrCount());
    utassert(root->NameIs("html"));
    HtmlElement *el = root->down;
    utassert(el->NameIs("head"));
    el = el->next;
    utassert(el->NameIs("body"));
    el = el->down;
    utassert(el->NameIs("object"));
    el = el->next;
    utassert(el->NameIs("ul"));
    el = el->down;
    utassert(el->NameIs("li"));
    el = el->down;
    utassert(el->NameIs("object"));
    ScopedMem<WCHAR> val(el->GetAttribute("type"));
    utassert(str::Eq(val, L"text/sitemap"));
    el = el->down;
    utassert(el->NameIs("param"));
    utassert(!el->down);
    utassert(el->next->NameIs("param"));
    el = p.FindElementByName("body");
    utassert(el);
    el = p.FindElementByName("ul", el);
    utassert(el);
    int count = 0;
    while (el) {
        ++count;
        el = p.FindElementByName("ul", el);
    }
    utassert(18 == count);
    free(d);
}
开发者ID:eminemence,项目名称:advancedoptionsui-sumatrapdf,代码行数:50,代码来源:TrivialHtmlParser_ut.cpp

示例5: CloseTag

void HtmlParser::CloseTag(char *tagName)
{
    str::ToLower(tagName);
    // to allow for lack of closing tags, e.g. in case like
    // <a><b><c></a>, we look for the first parent with matching name
    for (HtmlElement *el = currElement; el; el = el->up) {
        if (el->NameIs(tagName)) {
            currElement = el->up;
            return;
        }
    }
    // ignore the unexpected closing tag
}
开发者ID:mercutiodesign,项目名称:sumatrapdf,代码行数:13,代码来源:TrivialHtmlParser.cpp

示例6: CloseTag

void HtmlParser::CloseTag(HtmlToken *tok)
{
    char *tagName = NULL;
    if (Tag_NotFound == tok->tag) {
        tagName = (char *)tok->s;
        char *tagEnd = tagName + tok->nLen;
        *tagEnd = '\0';
    }

    // to allow for lack of closing tags, e.g. in case like
    // <a><b><c></a>, we look for the first parent with matching name
    for (HtmlElement *el = currElement; el; el = el->up) {
        if (tagName ? el->NameIs(tagName) : tok->tag == el->tag) {
            currElement = el->up;
            return;
        }
    }
    // ignore the unexpected closing tag
}
开发者ID:kindleStudy,项目名称:sumatrapdf,代码行数:19,代码来源:TrivialHtmlParser.cpp


注:本文中的HtmlElement::NameIs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。