本文整理汇总了C++中Xml::getRSSTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ Xml::getRSSTitle方法的具体用法?C++ Xml::getRSSTitle怎么用?C++ Xml::getRSSTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml::getRSSTitle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
//.........这里部分代码省略.........
}
// also use the title from the title tag, because sometimes it does not equal "tt->getTitle()"
int32_t a = tt->getTitleTagStart();
int32_t b = tt->getTitleTagEnd();
char *start = NULL;
char *end = NULL;
if ( a >= 0 && b >= 0 && b>a ) {
start = bodyWords->getWord(a);
end = bodyWords->getWord(b-1) + bodyWords->getWordLen(b-1);
if ( !addMatches( start, end - start, MF_TITLETAG ) ) {
return false;
}
}
// now add in the meta tags
int32_t n = bodyXml->getNumNodes();
XmlNode *nodes = bodyXml->getNodes();
// find the first meta summary node
for ( int32_t i = 0 ; i < n ; i++ ) {
// continue if not a meta tag
if ( nodes[i].m_nodeId != TAG_META ) continue;
// only get content for <meta name=..> not <meta http-equiv=..>
int32_t tagLen;
char *tag = bodyXml->getString ( i , "name" , &tagLen );
// is it an accepted meta tag?
int32_t flag = 0;
if (tagLen== 7&&strncasecmp(tag,"keyword" , 7)== 0)
flag = MF_METAKEYW;
if (tagLen== 7&&strncasecmp(tag,"summary" , 7)== 0)
flag = MF_METASUMM;
if (tagLen== 8&&strncasecmp(tag,"keywords" , 8)== 0)
flag = MF_METAKEYW;
if (tagLen==11&&strncasecmp(tag,"description",11)== 0)
flag = MF_METADESC;
if ( ! flag ) continue;
// get the content
int32_t len;
char *s = bodyXml->getString ( i , "content" , &len );
if ( ! s || len <= 0 ) continue;
// wordify
if ( !addMatches( s, len, flag ) ) {
return false;
}
}
// . now the link text
// . loop through each link text and it its matches
// loop through the Inlinks
Inlink *k = NULL;
for ( ; (k = linkInfo->getNextInlink(k)) ; ) {
// does it have link text? skip if not.
if ( k->size_linkText <= 1 ) {
continue;
}
// set the flag, the type of match
mf_t flags = MF_LINK;
// add it in
if ( !addMatches( k->getLinkText(), k->size_linkText - 1, flags ) ) {
return false;
}
// set flag for that
flags = MF_HOOD;
// add it in
if ( !addMatches( k->getSurroundingText(), k->size_surroundingText - 1, flags ) ) {
return false;
}
// parse the rss up into xml
Xml rxml;
if ( ! k->setXmlFromRSS ( &rxml ) ) {
return false;
}
// add rss description
bool isHtmlEncoded;
int32_t rdlen;
char *rd = rxml.getRSSDescription( &rdlen, &isHtmlEncoded );
if ( !addMatches( rd, rdlen, MF_RSSDESC ) ) {
return false;
}
// add rss title
int32_t rtlen;
char *rt = rxml.getRSSTitle( &rtlen, &isHtmlEncoded );
if ( !addMatches( rt, rtlen, MF_RSSTITLE ) ) {
return false;
}
}
// that should be it
return true;
}