#include#include #include #include using namespace boost::property_tree; OutputList parseDoc(std::string xml) { ptree pt; std::istringstream is(xml); read_xml(is, pt); OutputList list; for (ptree::value_type const& v : pt.get_child("") ) { if (boost::iequals(v.first, "item")) { list.push_back(v.second.data()); } } return list; } int main() { std::string xml = " "; OutputList list = parseDoc(xml); for (auto item : list) { std::cout << item << std::endl; } return 0; } - Apple
- Banana
- Mango
#includeIn this example, the TinyXML Library is used to parse an XML document and generate an OutputList of items. The function takes a string as input and returns the OutputList. The TinyXML Library is used to read the XML document and extract the items. Determining Package Library: From these examples, we can determine that the OutputList parseDoc function can be found in various libraries and packages such as Boost and TinyXML.#include "tinyxml2.h" using namespace tinyxml2; OutputList parseDoc(std::string xml) { XMLDocument doc; doc.Parse(xml.c_str()); OutputList list; XMLElement* element = doc.FirstChildElement("items"); if (element) { for (XMLElement* child = element->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) { list.push_back(child->GetText()); } } return list; } int main() { std::string xml = " "; OutputList list = parseDoc(xml); for (auto item : list) { std::cout << item << std::endl; } return 0; } - Apple
- Banana
- Mango