bool XmlDocument::R7eChildElements(sPtr parent, std::string newChildName, std::string newChildText, std::vector<std::string> newChildAttributes) { bool result = false; if ((parent != NULL) && (!parent->isSelfClose())) { sPtr newChild = makeTaggedElement(newChildName); if (!newChildText.empty()) newChild->addChild(makeTextElement(newChildText)); if (!newChildAttributes.empty()) { for (size_t i = 0; i < newChildAttributes.size(); i += 2) { newChild->addAttrib(newChildAttributes[i], newChildAttributes[i + 1]); } } cout << "\n child for root element" << newChild->toString() << endl; cout << "parent's number of children before adding new child... " << parent->children().size() << endl; parent->addChild(newChild); cout << "after adding new child...\n " << parent->toString() << endl; cout << "parent's number of children before adding new child... " << parent->children().size() << endl; result = true; } return result; }
std::vector<sPtr> XmlDocument::R8b(sPtr element) { std::vector<sPtr> children; children.empty(); if (element != NULL) { children = element->children(); } return children; }
/* * if tag == "" returns pElem and all decendents */ bool XmlDocument::find(const std::string& tag, sPtr pElem, bool findall) { if (pElem->tag() == tag || tag == "") { found_.push_back(pElem); if (!findall) return true; } for (auto pChild : pElem->children()) find(tag, pChild); return (found_.size() > 0); }