开发者

c++ how to create write an xml and how to read from it? [closed]

开发者_运维百科 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜