fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <boost/property_tree/ptree.hpp>
  4. #include <boost/property_tree/xml_parser.hpp>
  5.  
  6. void dump_ptree(const boost::property_tree::ptree &pt, std::string &&prefix = "")
  7. {
  8. for (auto &e : pt) {
  9. std::cout << prefix << e.first << std::endl;
  10. dump_ptree(e.second, prefix + "__");
  11. }
  12. }
  13.  
  14. int main()
  15. {
  16. boost::property_tree::ptree pt;
  17. read_xml(std::cin, pt);
  18. dump_ptree(pt);
  19. }
  20.  
Success #stdin #stdout 0s 4176KB
stdin
<div><p><a></a></p></div><span><p></p></span>
stdout
div
__p
____a
span
__p