本文整理汇总了C++中pugi::xml_node::text方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::text方法的具体用法?C++ xml_node::text怎么用?C++ xml_node::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::text方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergeNodes
void mergeNodes(pugi::xml_node toNode, pugi::xml_node& fromNode)
{
// Base case = both nodes are text nodes
pugi::xml_text fromNodeText = fromNode.text();
pugi::xml_text toNodeText = toNode.text();
if (fromNodeText && toNodeText) {
SBLog::info() << "Overwriting template value of \"" << toNode.name() << "\" from \"" << toNodeText.get() << "\" to \"" << fromNodeText.get() << "\"." << std::endl;
toNodeText.set(fromNodeText.get());
return;
}
// Calculate number of children in toNode
unsigned maxDistance = std::distance(toNode.begin(), toNode.end());
// Merge children
for (pugi::xml_node fromNodeChild = fromNode.first_child(); fromNodeChild; fromNodeChild = fromNodeChild.next_sibling()) {
// Find appropriate merge point
pugi::xml_node toNodeChild = findSimilarNode(fromNodeChild, toNode, maxDistance);
if (toNodeChild) {
mergeNodes(toNodeChild, fromNodeChild);
} else {
toNode.append_copy(fromNodeChild);
}
}
// Erase fromNode
removeNode(fromNode);
}
示例2: AddTextElementRaw
void AddTextElementRaw(pugi::xml_node node, const char* value)
{
wxASSERT(node);
wxASSERT(value);
if (*value)
node.text().set(value);
else {
node.text().set("");
}
}
示例3: CopyXmlNode
void XmlTools::CopyXmlNode(const pugi::xml_node& srcNode, pugi::xml_node& dstNode)
{
for (const pugi::xml_attribute& attr : srcNode.attributes())
{
auto attrCopy = dstNode.append_attribute(attr.name());
attrCopy.set_value(attr.value());
}
for (const pugi::xml_node& node : srcNode.children())
{
auto nodeCopy = dstNode.append_child(node.name());
CopyXmlNode(node, nodeCopy);
}
auto nodeText = srcNode.text();
dstNode.text().set(nodeText.as_string());
}
示例4: FromXml
static
void FromXml(const pugi::xml_node& xmlNode, DataSetElement& parent)
{
// ignore non-named XML nodes
//
// pugi::xml separates XML parts into more node types than we use
//
const string& label = xmlNode.name();
if (label.empty())
return;
// label & text
DataSetElement e(xmlNode.name(), FromInputXml());
e.Text(xmlNode.text().get());
// iterate attributes
auto attrIter = xmlNode.attributes_begin();
auto attrEnd = xmlNode.attributes_end();
for ( ; attrIter != attrEnd; ++attrIter )
e.Attribute(attrIter->name(), attrIter->value());
// iterate children, recursively building up subtree
auto childIter = xmlNode.begin();
auto childEnd = xmlNode.end();
for ( ; childIter != childEnd; ++childIter ) {
pugi::xml_node childNode = *childIter;
FromXml(childNode, e);
}
// add our element to its parent
parent.AddChild(e);
}
示例5: LoadItemAttribute
void CDuiListBox::LoadItemAttribute(pugi::xml_node xmlNode, LPLBITEM pItem)
{
pItem->nImage=xmlNode.attribute("img").as_int(pItem->nImage);
pItem->lParam=xmlNode.attribute("data").as_uint(pItem->lParam);
pItem->strText = DUI_CA2T(xmlNode.text().get(), CP_UTF8);
DuiStringPool::getSingleton().BuildString(pItem->strText);
}
示例6: InitFromXml
BOOL RichEditText::InitFromXml(pugi::xml_node xmlNode)
{
m_strText = xmlNode.text().get();
// 计算行数
for (int nlf = m_strText.Find(0x0a); nlf >= 0; ++m_nLineCount)
{
nlf = m_strText.Find(0x0a, nlf+1);
}
return __super::InitFromXml(xmlNode);
}
示例7: readData
bool GraphMLParser::readData(
GraphAttributes &GA,
const edge &e,
const pugi::xml_node edgeData)
{
pugi::xml_attribute keyId = edgeData.attribute("key");
if (!keyId) {
GraphIO::logger.lout() << "Edge data does not have a key." << endl;
return false;
}
const long attrs = GA.attributes();
pugi::xml_text text = edgeData.text();
switch(graphml::toAttribute(m_attrName[keyId.value()])) {
case graphml::a_edgeLabel:
if(attrs & GraphAttributes::edgeLabel) {
GA.label(e) = text.get();
}
break;
case graphml::a_edgeWeight:
if(attrs & GraphAttributes::edgeIntWeight) {
GA.intWeight(e) = text.as_int();
} else if(attrs & GraphAttributes::edgeDoubleWeight) {
GA.doubleWeight(e) = text.as_double();
}
break;
case graphml::a_edgeType:
if(attrs & GraphAttributes::edgeType) {
GA.type(e) = graphml::toEdgeType(text.get());
}
break;
case graphml::a_edgeArrow:
if(attrs & GraphAttributes::edgeArrow) {
GA.arrowType(e) = graphml::toArrow(text.get());
}
break;
case graphml::a_edgeStroke:
if(attrs & GraphAttributes::edgeStyle) {
GA.strokeColor(e) = text.get();
}
break;
default:
GraphIO::logger.lout(Logger::LL_MINOR) << "Unknown edge attribute with \""
<< keyId.value()
<< "\"." << endl;
}
return true;
}
示例8: AddTextElementUtf8
void AddTextElementUtf8(pugi::xml_node node, std::string const& value)
{
assert(node);
node.text().set(value.c_str());
}
示例9: AddTextElement
void AddTextElement(pugi::xml_node node, int64_t value)
{
assert(node);
node.text().set(static_cast<long long>(value));
}
示例10: for_each
virtual bool for_each(pugi::xml_node& node) {
Log::log(logModule, level, "XML node type = [%s], name = [%s], value = [%s]",
node_types[node.type()], node.name(),
node.type() == pugi::node_cdata || node.type() == pugi::node_pcdata ? node.text().get() : node.value());
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
Log::log(logModule, level, " attribute name = [%s], value = [%s]",
ait->name(), ait->value());
}
return true;
}