c++ how to create write an xml and how to read from it? [closed]
I am working in Ubuntu. I would like to create serialize an object. Because I didn't find any library in c++ that can help me, I am going to write the XML by my own. I would like to ask how to do that. It is ok if I say:
std::string xml = "<?xml..."+"<name>%s</name>\n"+"<birthdate>%d</birthdate>"...+name,date;
Can you please tell me if it's ok? One more question : how to do the deserialization? Is there a library that reads an xml and prints the values that you would like? I am working in c++ code. THX!
EDIT:
.h
//code
class people
{
public:
people();
std::string name;
std::string birthday;
int number;
};
.cpp
//code
people *p = new people();
p.name="me";
p.birthday=11;
p.number=1;
I would like to create an XML file based on *p. How to do it with libxml++ or any library? After this I would also want the deserialization of course.
For a C++ serialization library see Boost as per @Begemoth 's comment see Boost tutorial - code does not have to be added to the class.
精彩评论