本文整理汇总了C++中HtmlToken::NextAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ HtmlToken::NextAttr方法的具体用法?C++ HtmlToken::NextAttr怎么用?C++ HtmlToken::NextAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlToken
的用法示例。
在下文中一共展示了HtmlToken::NextAttr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parser
// Parse s in place i.e. we assume we can modify it. Must be 0-terminated.
// The caller owns the memory for s.
HtmlElement *HtmlParser::ParseInPlace(char *s, UINT codepage)
{
if (this->html)
Reset();
this->html = s;
this->codepage = codepage;
HtmlPullParser parser(s, strlen(s));
HtmlToken *tok;
while ((tok = parser.Next())) {
char *tag = (char *)tok->s;
if (tok->IsError()) {
errorContext = tag;
switch (tok->error) {
case HtmlToken::UnclosedTag: return ParseError(ErrParsingElementName);
case HtmlToken::InvalidTag: return ParseError(ErrParsingClosingElement);
default: return ParseError(ErrParsingElement);
}
}
if (!tok->IsTag()) {
// ignore text content
assert(tok->IsText());
continue;
}
char *tagEnd = tag + tok->nLen;
if (!tok->IsEndTag()) {
// note: call tok->NextAttr() before zero-terminating names and values
AttrInfo *attr = tok->NextAttr();
*tagEnd = '\0';
StartTag(tag);
while (attr) {
char *name = (char *)attr->name;
char *nameEnd = name + attr->nameLen;
char *value = (char *)attr->val;
char *valueEnd = value + attr->valLen;
attr = tok->NextAttr();
*nameEnd = *valueEnd = '\0';
AppendAttr(name, value);
}
}
if (!tok->IsStartTag() || IsTagSelfClosing(tok->tag)) {
*tagEnd = '\0';
CloseTag(tag);
}
}
return rootElement;
}