1

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Because you just know someone's going to come along with a & or < and screw it all up.
@Ignacio, true, however, it still seems a little overkill for just replacing 5 entities (which you can do yourself!!) :)
1

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

1 Comment

How do i get the number of childnodes in a given node? Any idea?
1

libxml++

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

1 Comment

There are so many version. Which one to download? Can you give me a link?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.