tags:

views:

58

answers:

3

Need to write some C++ code that reads XML string and if i do

something like: get valueofElement("ACTION_ON_CARD") it returns 3
get valueofElement("ACTION_ON_ENVELOPE") it returns YES

XML String:

<ACTION_ON_CARD>3</ACTION_ON_CARD>
<ACTION_ON_ENVELOPE>YES</ACTION_ON_ENVELOPE>

Any code example would be helpfull

Thanks

+2  A: 

writing an xml parser is not necessarily an easy thing to do, so unless it is a requirement you do it yourself I suggest you get a library to do that for you.

There are many available like xerces (pretty complete but not exactly simple), tinyxml (mostly the opposite of xerces, it probably suits best your needs) or libxml (never tried this one)

f4
A: 

I recommend the XML parser from the Poco C++ library. It's well documented and easy to use.

StackedCrooked
A: 

If you have the schema, you could use codesynthesis xsd compiler.

paquetp