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; }
// ---------------< create xml element for file and its dependencies >------------- sPtr ClientHandler::makeFileElement(sPtr pRoot, std::string package, std::string filename, std::vector<std::string> deps) { sPtr file = makeTaggedElement("file"); file->addChild(makeTextElement(filename)); sPtr depNames = makeTaggedElement("deps"); for (auto depName : deps) { sPtr dep = makeTaggedElement("dep"); dep->addChild(makeTextElement(depName)); depNames->addChild(dep); } file->addChild(depNames); pRoot->addChild(file); return pRoot; }