Reversed
Reversed

Reputation: 51

How to get values of attributes on a XML file using C++?

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

Upvotes: 0

Views: 1010

Answers (3)

paquetp
paquetp

Reputation: 1651

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

Upvotes: 1

StackedCrooked
StackedCrooked

Reputation: 35485

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

Upvotes: 0

f4.
f4.

Reputation: 3852

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)

Upvotes: 2

Related Questions