本文整理汇总了C++中DOMElement::getChildElementCount方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::getChildElementCount方法的具体用法?C++ DOMElement::getChildElementCount怎么用?C++ DOMElement::getChildElementCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getChildElementCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSubElementValues
// http://thelastpcbender.blogspot.com/2008/11/introduction-to-xerces-c-domparser.html
std::string CXercesUtils::GetSubElementValues(DOMElement* e , std::vector<std::string> &excludes)
{
std::string value;
DOMNodeList * Child = e-> getChildNodes();
const XMLSize_t nc = Child->getLength();
//now we traverse the tree, note that we use XMLSize_t instead of int
//
for(XMLSize_t i=0; i< nc; i++)
{
DOMNode* currentNode = Child->item(i);
if(currentNode && currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE )
{
DOMElement* currentElem = (DOMElement*) currentNode;
std::string elemname = GetElementName(currentElem );
if(std::find(excludes.begin(), excludes.end(), elemname) != excludes.end())
continue;
if(currentElem->getChildElementCount() == (XMLSize_t) 0)
{
value+=GetElementName(currentElem );
value+="=";
value+=GetElementValue(currentElem );
value+="<br>";
}
// recursively add items
else
{
value+=GetSubElementValues(currentElem , excludes) ;
}
}
}
return value;
}
示例2: DumpTree
void CXercesUtils::DumpTree (DOMNode *tree, std::string &tmp)
{
tabs+="\t";
if (tree != NULL)
{
if (tree->getNodeType () != DOMNode::ELEMENT_NODE)
goto leave;
DOMElement* e = (DOMElement* ) tree;
std::string el_name = XMLString::transcode(tree->getNodeName());
std::string el_value;
if(e->getTextContent () && e->getChildElementCount() == (XMLSize_t) 0)
el_value = XMLString::transcode(e->getTextContent ());
tmp+= tabs + "<"+ el_name + ">" + el_value + "\n";
for (DOMNode* child = tree->getFirstChild();
child != NULL; child = child->getNextSibling())
{
DumpTree(child, tmp);
}
tmp+= tabs + "</" + el_name + ">\n";
}
leave:
tabs+=tabs.substr(1);
}
示例3: NagivateParseTree
// Look at Xerces XSModel to parse XSD into tree SCMPrint
void CXercesUtils::NagivateParseTree(xercesc::DOMElement* p, std::string tabs)
{
string name;
short age;
tabs+=" ";
for (DOMNode* n = p->getFirstChild (); n != 0; n = n->getNextSibling ())
{
if (n->getNodeType () != DOMNode::ELEMENT_NODE)
continue;
DOMElement* e = (DOMElement* ) n;
std::string el_name = XMLString::transcode(n->getNodeName());
std::string el_value;
if(e->getTextContent () && e->getChildElementCount() == (XMLSize_t) 0)
el_value = XMLString::transcode(e->getTextContent ());
std::cerr << tabs.c_str() << el_name.c_str()<< "=" << el_value.c_str()<< endl;
//DOMNode* node = n->getFirstChild ();
NagivateParseTree((DOMElement*) n,tabs);
}
tabs=tabs.substr(1);
}