subs
subs

Reputation: 2249

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 parameter 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.

Upvotes: 1

Views: 4781

Answers (3)

rplusg
rplusg

Reputation: 3446

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

Upvotes: 1

Nim
Nim

Reputation: 33655

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.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799470

libxml++

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

Upvotes: 1

Related Questions