bool XMLElement::getSubElement(const std::string& name, XMLElement& subElement) const { bool found = false; #ifdef PUGIXML for (XMLElement subNode = getFirstSubElement(); subNode.isValid(); subNode.nextSibling()) { found = subNode.findSubElement(name, subElement); if (found) { break; } } #else if (nodePtr && nodePtr->children) { // Do a depth-first search of all of the descendant nodes. for (XMLElement subNode = getFirstSubElement(); subNode.isValid(); subNode.nextSibling()) { found = subNode.findSubElement(name, subElement); if (found) { break; } } } if (!found) subElement.nodePtr = NULL; #endif return found; }
bool XMLElement::hasSubElements() const { bool found = false; if (nodePtr && nodePtr->hasChildNodes() == VARIANT_TRUE) { found = getFirstSubElement().isValid(); } return found; }
bool XMLElement::findSubElement(const std::string& name, XMLElement& subElement) const { bool found = false; #ifdef PUGIXML if (matchesXMLString(name, nodePtr.name())) { subElement = *this; found = true; } else { /*for (pugi::xml_node_iterator it = nodePtr.begin(); it != nodePtr.end(); ++it) { if (matchesXMLString(name, it->name())) { subElement = XMLElement(*it); found = true; break; } }*/ for (XMLElement subNode = getFirstSubElement(); subNode.isValid(); subNode.nextSibling()) { found = subNode.findSubElement(name, subElement); if (found) { break; } } } #else if (matchesXMLString(name, nodePtr->name)) { subElement = *this; found = true; } else if (nodePtr->children) { // This is not the correct node so do a depth-first search // of all of the descendant nodes. for (XMLElement subNode = getFirstSubElement(); subNode.isValid(); subNode.nextSibling()) { found = subNode.findSubElement(name, subElement); if (found) { break; } } } #endif return found; }
bool XMLElement::getSubElement(const std::string& name, XMLElement& subElement) const { bool found = false; if (nodePtr && nodePtr->hasChildNodes() == VARIANT_TRUE) { for (XMLElement subNode = getFirstSubElement(); subNode.isValid(); subNode.nextSibling()) { found = subNode.findSubElement(name, subElement); if (found) { break; } } } if (!found) subElement.nodePtr = NULL; return found; }
bool XMLElement::findSubElement(const std::string& name, XMLElement& subElement) const { bool found = false; BSTR bstr; if (nodePtr) { if ((nodePtr->get_nodeName(&bstr)) == S_OK) { if (matchesXMLString(name, bstr)) { subElement = *this; found = true; } } if (found == false && nodePtr->hasChildNodes() == VARIANT_TRUE) { for (XMLElement subNode = getFirstSubElement(); subNode.isValid(); subNode.nextSibling()) { found = subNode.findSubElement(name, subElement); if (found) break; } } } return found; }
bool XMLElement::hasSubElements() const { return getFirstSubElement().isValid(); }
bool XmlElement::hasSubElement(std::string subElementName) const { return (getFirstSubElement(subElementName) != NULL); } // hasSubElement