本文整理汇总了C++中LLXmlTreeNode::getContents方法的典型用法代码示例。如果您正苦于以下问题:C++ LLXmlTreeNode::getContents方法的具体用法?C++ LLXmlTreeNode::getContents怎么用?C++ LLXmlTreeNode::getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLXmlTreeNode
的用法示例。
在下文中一共展示了LLXmlTreeNode::getContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTextContents
std::string LLXmlTreeNode::getTextContents()
{
std::string msg;
LLXmlTreeNode* p = getChildByName("p");
if (p)
{
// Case 1: node has <p>text</p> tags
while (p)
{
msg += p->getContents() + "\n";
p = getNextNamedChild();
}
}
else
{
std::string::size_type n = mContents.find_first_not_of(" \t\n");
if (n != std::string::npos && mContents[n] == '\"')
{
// Case 2: node has quoted text
S32 num_lines = 0;
while(1)
{
// mContents[n] == '"'
++n;
std::string::size_type t = n;
std::string::size_type m = 0;
// fix-up escaped characters
while(1)
{
m = mContents.find_first_of("\\\"", t); // find first \ or "
if ((m == std::string::npos) || (mContents[m] == '\"'))
{
break;
}
mContents.erase(m,1);
t = m+1;
}
if (m == std::string::npos)
{
break;
}
// mContents[m] == '"'
num_lines++;
msg += mContents.substr(n,m-n) + "\n";
n = mContents.find_first_of("\"", m+1);
if (n == std::string::npos)
{
if (num_lines == 1)
{
msg.erase(msg.size()-1); // remove "\n" if only one line
}
break;
}
}
}
else
{
// Case 3: node has embedded text (beginning and trailing whitespace trimmed)
msg = mContents;
}
}
return msg;
}