开发者

Creating an Xml string in C++

I have an array of strings.I want to make an xml string using the values of the array elements. I will pass this xml string as a param开发者_如何学Goeter to a .net webservice. Can anybody please tell me how do I make an xml string in c++? What library do I have to use and what are the methods?

The xml structure:

<xml>
<DeviceName></devicename>
<State></State>
<xml>

It wont have any attribute.Each array element will have devicename and state info. I dont want to write this into a file. i just want to create a string, which i can pass as a parameter to a webmethod.


Erm, if you are just creating a string, why don't you simply do that? i.e.

std::ostringstream xml;

xml << "<?xml version=\"1.0\"?><some node><some child node/><some child node/></some node>";

xml.str(); // voila, here is your xml string...

No need to make it complicated..

If you REALLY do need a DOM, try TinyXML.


I use cmarkup, pretty simple to use. http://www.firstobject.com/dn_markup.htm


libxml++

Just keep using xmlpp::Node::add_child().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜