fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <vector>
  5. #include <boost/property_tree/ptree.hpp>
  6. #include <boost/property_tree/xml_parser.hpp>
  7. #include <boost/foreach.hpp>
  8.  
  9. int main() {
  10. using boost::property_tree::ptree;
  11. std::string xml_str =
  12. "<main>"
  13. "<owner>Matt</owner>"
  14. "<cats>"
  15. "<cat>Scarface Max</cat>"
  16. "<cat>Moose</cat>"
  17. "<cat>Snowball</cat>"
  18. "<cat>Powerball</cat>"
  19. "<cat>Miss Pudge</cat>"
  20. "<cat>Needlenose</cat>"
  21. "<cat>Sweety Pie</cat>"
  22. "<cat>Peacey</cat>"
  23. "<cat>Funnyface</cat>"
  24. "</cats>"
  25. "</main>";
  26. ptree pt;
  27. std::stringstream ss; ss << xml_str;
  28. read_xml(ss, pt);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty