Read XML on LINUX - c++

I have requirement where we have to read a small XML file on Linux. Our application is in C++ and I like to use any light weight XML library. Please suggest me the library.
Thanks

You can Try pugixml Light-weight, simple and fast XML parser for C++
As a 2nd option look at TinyXML

Have a look also at TinyXml (http://sourceforge.net/projects/tinyxml). It is extremely lightweight and for this reason it is used also in mobile and game programming. The API is minimal though so you have to evaluate if it fully satisfy your needs.

This xml parser is good

There is xerces-c for that. It's complete, but I don't know if you will find it small enough. Your question is relative to what?

Related

Parsing xml file using xerces C++

I have an xml file to be parsed for the information contained to be further used. Can anyone help me with the xerces C++ code for parsing it? I have the xml creation code using xerces library as well in C++.
Maybe this doesn't help you much if you're already committed to xerces, but I'd recommend using pugixml instead. It's very easy to integrate, is very performant and has excellent documentation. I built a rather large project using it and had nothing but good experiences with it. It's of the nicest libraries I've ever used. (I'm not affiliated with them; just very happy).
Here is the documentation on parsing files: http://pugixml.googlecode.com/svn/tags/latest/docs/manual/access.html

Streaming/progressive C++ XML creation library?

I'm looking for an XML library that writes out the XML stream as it goes. I've looked at TinyXML, pugixml, etc. and it seems these only write the stream when the entire DOM is built in memory. I want a library that will write each object as soon as all children and attributes are available. Is there such a thing?
The word you're looking for is SAX.
Xerces is one such C++ SAX library. If you're in the MS world then MSXML supports SAX2 too.
I wrote my own library in the end. I'm willing to share the source if it's of interest to anyone - it's a little clunky and minimal though.

Does anyone know C++ XML parser/writer similar to .Net's XML Document?

I'm writing a native C++ project and I need a simple XML parser/writer. I already know XmlDocument in C#, so something similar could be quite good, but if there isn't, does anyone know a quick-to-use XML parser/writer?
I'm trying to shorten my "learning of the library" time to minimum.
Thanks!
There are quite a few you can consider:
Xerces
TinyXML
libxml++
Expat Xml
XmlLite
I've used TinyXML, and it's worked reasonably well for what I've needed. My needs weren't terribly demanding though. At least when I used it, it didn't deal with DTD/XSD at all, so if you need to handle those it's probably not an option.
I ended up using RapidXML (http://rapidxml.sourceforge.net/).
For me, its intuitive, and was really easy to learn.
No body recommended it so I added my own answer :-\ ...

Best XML Library in C++, Fast Set-Up

I was wondering what is the best XML Library in C++ (I'm using Visual Studio), considering fast set-up is critical. Basically, I want to create a file to save annotations on various .avi files.
Thank you in advance.
You should be able to get TinyXML set up and working in a matter of minutes.
TinyXML is simple enough for almost all your use (if you don't bother having the whole xml representation in memory) but other libraries offer better important features :
RapidXML is made to be really really fast. It's used in the boost::property_tree library for the xml file read/write features. If you already use boost, using directly boost::property_tree might be a good idea, if adequate, as you already can easily use it with it's simple interface.
pugiXML has been mentionned as a good replacement for RapidXML by someone on the boost mailing list, but I'm not aware of the differences.
Xerces-C++ is made to allow you high level manipulations on xml like validation using xsd files -- but is really heavy on both speed and memory size...
wrappers around classic C xml libraries (like LibXML2) might be interesting choice if you don't find what you're looking for with the previous ones...
I've used XercesC++ in the past and it was relatively painless to get working and working with.
I'm currently using MSXML and it is painful.

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
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)
If you have the schema, you could use codesynthesis xsd compiler.
I recommend the XML parser from the Poco C++ library. It's well documented and easy to use.