-
June 26th, 2011, 04:07 AM
#1
XML Parsing using C++
Hi,
My requirement is this. I have an .XML file. Using this file i would like to drive my program.
For the same i would like to parse my .XML file. Which C++ headers and class files will help me to do this. Give few reference spots also.
I am using VS 2008.
Thanks
Dave
-
June 26th, 2011, 07:37 AM
#2
Re: XML Parsing using C++
you can use Tiny XML
http://sourceforge.net/projects/tinyxml/
or you can use Full C++ Toolkits like QT or Wxwigdet
they provide more comprehensive development
-
June 26th, 2011, 10:55 AM
#3
Re: XML Parsing using C++
I don't want to use a third party library.
I want to use native C++ for doing the same .
Let me know the header file for support this.
Thanks
Dave
-
June 26th, 2011, 11:01 AM
#4
Re: XML Parsing using C++
I'm not shure what you understand by "native C++". if you mean std c++ then no there is no xml parser class.
Kurt
-
June 26th, 2011, 11:25 AM
#5
Re: XML Parsing using C++
Originally Posted by Dave1024
I want to use native C++ for doing the same .
Let me know the header file for support this.
There aren't any standard C++ classes that do XML parsing.
Either you use one of the well-established C++ XML parsers out there ( a google search will reveal them to you), or you have to write your own.
Regards,
Paul McKenzie
-
June 29th, 2011, 08:00 AM
#6
Re: XML Parsing using C++
there is not such thing a native C++ , ( except if you take into account STL which is again a library ) , try to separate in your mind the libraries which are used by C++ to language construct C++ ( which is keyword and syntax which make the language)
So my suggestion would be to go with third party library.
-
June 30th, 2011, 08:08 AM
#7
Re: XML Parsing using C++
Originally Posted by Dave1024
I have an .XML file. Using this file i would like to drive my program.
If you are using this file to configure your program, then XML might not be the format of choice.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
June 30th, 2011, 12:00 PM
#8
Re: XML Parsing using C++
Originally Posted by aamir121a
there is not such thing a native C++
Well, there is, but that term is usually used as a contrast to Managed C++/CLI which is not what the OP intended.
The C++ Standard Libraries do not include XML parsers. Boost (which is sort of the standard library's extended family) may have something, I'm not sure.
The one I've used in the past to good effect is libxml2. It's not very hard to use.
-
July 1st, 2011, 03:00 AM
#9
Re: XML Parsing using C++
Originally Posted by Lindley
Boost (which is sort of the standard library's extended family) may have something, I'm not sure.
there is boost property tree; it's easy to use, STL-like and very flexible but it supports only basic xml-parsing, no validation of any sort, xpath or transforms, just a translation of the xml tree into a std::map like tree container. It's very helpful because of its interaction with iostream and boost lexical cast which makes insertion/extraction of "properties" in the tree easy and expressive; moreover, it has the added benefit of parsing from/to different file formats, like json and ini.
Originally Posted by monarch_dodra
If you are using this file to configure your program, then XML might not be the format of choice.
I thought xml was the most common format in this scenario, isn't it ?
-
July 8th, 2011, 09:21 AM
#10
Re: XML Parsing using C++
I thought xml was the most common format in this scenario, isn't it ?[/QUOTE]
XML is mostly used to transfer or store structured data, in some form of universal format.
If the requirement is just have a file to describe your program's configurations at startup, the using XML is overkill. A good old fashion textual .ini file well get the work done just as well.
Since the op wasn't very clear about his needs, I just thought I'd throw it in there.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|