Exemplo n.º 1
0
AttrInfo *HtmlToken::GetAttrByName(const char *name)
{
    nextAttr = NULL; // start from the beginning
    for (AttrInfo *a = NextAttr(); a; a = NextAttr()) {
        if (a->NameIs(name))
            return a;
    }
    return NULL;
}
Exemplo n.º 2
0
static void Test00(const char *s, HtmlToken::TokenType expectedType) {
    HtmlPullParser parser(s, str::Len(s));
    HtmlToken *t = parser.Next();
    assert(t->type == expectedType);
    assert(t->NameIs("p"));
    assert(Tag_P == t->tag);
    AttrInfo *a = t->GetAttrByName("a1");
    assert(a->NameIs("a1"));
    assert(a->ValIs(">"));

    a = t->GetAttrByName("foo");
    assert(a->NameIs("foo"));
    assert(a->ValIs("bar"));

    a = t->GetAttrByName("nope");
    assert(!a);

    t = parser.Next();
    assert(!t);
}