/** * Returns list of sub-nodes for a xpath node * For: xpath = //Data/ * Returns: Detector , DetectorWing */ std::vector<std::string> XmlHandler::get_subnodes(const std::string &xpath) { std::vector<std::string> subnodes; Poco::XML::Node *xpathNode = pDoc->getNodeByPath(xpath); Poco::XML::NodeIterator it(xpathNode, Poco::XML::NodeFilter::SHOW_ELEMENT); Poco::XML::Node *pNode = it.nextNode(); while (pNode) { if (pNode->childNodes()->length() == 1) { subnodes.push_back(pNode->nodeName()); } pNode = it.nextNode(); } return subnodes; }
/** * Build dictionary {string : string } of all tags in the dictionary * Composed tags: / replaced by _ * */ std::map<std::string, std::string> XmlHandler::get_metadata(const std::string &tag_to_ignore) { std::map<std::string, std::string> metadata; Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT); Poco::XML::Node *pNode = it.nextNode(); while (pNode) { if (pNode->childNodes()->length() == 1 && pNode->nodeName() != tag_to_ignore) { std::string key = pNode->parentNode()->nodeName() + "/" + pNode->nodeName(); std::string value = pNode->innerText(); metadata.emplace(key, value); } pNode = it.nextNode(); } return metadata; }