本文整理汇总了C++中HtmlParser::TotalAttrCount方法的典型用法代码示例。如果您正苦于以下问题:C++ HtmlParser::TotalAttrCount方法的具体用法?C++ HtmlParser::TotalAttrCount怎么用?C++ HtmlParser::TotalAttrCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlParser
的用法示例。
在下文中一共展示了HtmlParser::TotalAttrCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
static void HtmlParser09()
{
HtmlParser p;
HtmlElement *root = p.Parse("<?xml version='1.0'?><!-- <html><body></html> --><root attr='<!-- comment -->' />");
assert(1 == p.ElementsCount());
assert(1 == p.TotalAttrCount());
assert(str::Eq("root", root->name));
ScopedMem<TCHAR> val(root->GetAttribute("attr"));
assert(str::Eq(val, _T("<!-- comment -->")));
root = p.Parse("<!-- comment with \" and \' --><main />");
assert(1 == p.ElementsCount());
assert(0 == p.TotalAttrCount());
assert(str::Eq("main", root->name));
}
示例2: utassert
static void HtmlParser11()
{
HtmlParser p;
HtmlElement *root = p.Parse("<root/><!-- comment -->");
utassert(1 == p.ElementsCount());
utassert(0 == p.TotalAttrCount());
utassert(root && root->NameIs("root"));
root = p.Parse("<root><!---></root>");
utassert(!root);
}
示例3: HtmlParserFile
static void HtmlParserFile()
{
TCHAR *fileName = _T("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<TCHAR> exePath(GetExePath());
const TCHAR *exeDir = path::GetBaseName(exePath);
ScopedMem<TCHAR> p1(path::Join(exeDir, _T("..\\src\\utils")));
ScopedMem<TCHAR> 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);
assert(root);
assert(709 == p.ElementsCount());
assert(955 == p.TotalAttrCount());
assert(str::Eq(root->name, "html"));
HtmlElement *el = root->down;
assert(str::Eq(el->name, "head"));
el = el->next;
assert(str::Eq(el->name, "body"));
el = el->down;
assert(str::Eq(el->name, "object"));
el = el->next;
assert(str::Eq(el->name, "ul"));
el = el->down;
assert(str::Eq(el->name, "li"));
el = el->down;
assert(str::Eq(el->name, "object"));
ScopedMem<TCHAR> val(el->GetAttribute("type"));
assert(str::Eq(val, _T("text/sitemap")));
el = el->down;
assert(str::Eq(el->name, "param"));
assert(!el->down);
assert(str::Eq(el->next->name, "param"));
el = p.FindElementByName("body");
assert(el);
el = p.FindElementByName("ul", el);
assert(el);
int count = 0;
while (el) {
++count;
el = p.FindElementByName("ul", el);
}
assert(18 == count);
free(d);
}