4 #include <samchon/library/XML.hpp> 22 auto toXML() const ->
std::shared_ptr<library::
XML>
24 std::shared_ptr<library::XML> xml(
new library::XML());
25 xml->setTag(
"member");
27 xml->setProperty(
"id",
id);
28 xml->setProperty(
"name", name);
29 xml->setProperty(
"age", age);
30 xml->setProperty(
"grade", grade);
42 shared_ptr<XML> xml(
new XML());
43 xml->setTag(
"memberArray");
46 vector<struct Member> memberArray =
48 {
"samchon",
"Jeongho Nam", 27, 1 },
49 {
"gkyu",
"Kwangkyu Ko", 25, 1 },
50 {
"guest",
"John Doe", 99, 4 }
52 for (
size_t i = 0; i < memberArray.size(); i++)
53 xml->push_back(memberArray[i].toXML());
60 "<file extension='pdf' name='API' />" +
61 "<file extension='pdf' name='Guidance+For+Developer'>Damaged</file>" +
62 "<file extension='docx' name='Resume' />" +
63 "<file extension='jpg' name='My+House' />" +
64 "<file extension='xlsx' name='Grades' />" +
68 cout <<
"-----------------------------------------------------------------" << endl;
69 cout <<
" Get Properties And Values" << endl;
70 cout <<
"-----------------------------------------------------------------" << endl;
71 cout <<
"Age of 2nd member: " << xml->get(
"member")->at(1)->getProperty<
int>(
"age") << endl;
72 cout <<
"Age of 1st member: " << xml->get(
"member")->at(0)->getProperty(
"id") << endl << endl;
74 cout <<
"File name and extension of 5th: " 75 << xml->get(
"fileList")->at(0)->get(
"file")->at(4)->getProperty(
"name") <<
"." 76 << xml->get(
"fileList")->at(0)->get(
"file")->at(4)->getProperty(
"extension") << endl;
77 cout <<
"Value of 2nd file: " << xml->get(
"fileList")->at(0)->get(
"file")->at(1)->getValue() << endl << endl;
79 cout <<
"-----------------------------------------------------------------" << endl;
80 cout <<
" XML to String: " << endl;
81 cout <<
"-----------------------------------------------------------------" << endl;
82 cout << xml->toString() << endl;