XML Parsing

This is a discussion on XML Parsing within the C++ Programming forums, part of the General Programming Boards category; I'm trying to pass into my C++ linux application an XML document, which is describing some algorithm, that should be ...

  1. #1
    Registered User Mareq's Avatar
    Join Date
    Nov 2005
    Location
    Bratislava
    Posts
    7

    Question XML Parsing

    I'm trying to pass into my C++ linux application an XML document, which is describing some algorithm, that should be executed by application. I need to sequentially parse this document and after reading some value from it, immediately execute appropriate action described by that value.

    How should I parse that XML document and which XML parser should I choose? Actually, after reading some tutorials, I had already chosen IBM's xml4c2, but is it good decision?

    What exactly does it mean "SAX" and what is it good for?

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    I don't know really. People have recommended tinyXML to me but I could never understand it properly

  3. #3
    Registered User Mareq's Avatar
    Join Date
    Nov 2005
    Location
    Bratislava
    Posts
    7
    Why did they recommend you just TinyXML? Is there some good reason for it?

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    I don't really know it just seems to be popular. Probably because it is small and functional but there are other libraries out there to try.

    http://www.grinninglizard.com/tinyxml/

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    What exactly does it mean "SAX" and what is it good for?
    It's a method of reading in the XML file.

    [edit]
    Google for "XML SAX" or try this for SAX info.
    [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    sax is a method for parsing XML (Simple API for XML), it means basically that you parse the document using callbacks, such as onChar() for character data, onBeginElement and onEndElement. Using SAX you can process the document while parsing it and make it recover from XML errors if necessary. The other popular method is using a DOM parse (Document Object Model) where you give the parser an XML document and it give you back sort of a tree structure. The DOM type has larger memory requirements because it creates a data structure out of all the data. Typically when doing web services and such, you would use SAX, but when using an XML document as a file data structure or something like that, you would be more likely to use DOM.

    In the past, I've used both expat and xerces, both open source.

  7. #7
    Registered User Mareq's Avatar
    Join Date
    Nov 2005
    Location
    Bratislava
    Posts
    7
    Thank you very much for explaining SAX & DOM.

    About parsers... There are really very huge amount of them and I really do not know, which one I should use. My case, I think, is SAX parser, because I am parsing (and "executing") XML document describing commands for my application, so I need event driven approach. I am glad, you mentioned expat, because my friends recommended it to me, too. Now, there are three candidates: expat, xerces and IBM's xml4c2. Could you please very shortly describe differences between them (are they significant for me?), so I can choose the best way (if there is one)? Most significant for me is parser speed (my application should run real-time), but I also need very robust parser, which is capable of some error checking (not correcting errors, just pass as exact error description as possible) and also XML file is very complex.
    Last edited by Mareq; 11-06-2005 at 07:30 PM.

  8. #8
    Registered User Mareq's Avatar
    Join Date
    Nov 2005
    Location
    Bratislava
    Posts
    7

    Unhappy

    So is there anybody out there, who have some experience with XML parsers and is willing to share it with me?

  9. #9
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    I would recommend using expat, it's small, fast and efficient. Xerces I've only used in java, I don't know if they have a C version of it, but you won't go wrong with expat, I've used it on the server side sometimes handling 400 connections per minute, each with XML to parse. They will all have the same interface if they support SAX, so they should be pretty much equally simple to use.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parsing Xml
    By deviousdexter in forum C# Programming
    Replies: 7
    Last Post: 04-24-2009, 06:29 AM
  2. Parsing XML with C without 3rd party libs
    By mike_morley in forum C Programming
    Replies: 13
    Last Post: 12-18-2008, 01:21 PM
  3. xml file parsing in C
    By lonbgeach in forum Tech Board
    Replies: 31
    Last Post: 12-14-2006, 01:14 AM
  4. Parsing XML in C++
    By CompiledMonkey in forum C++ Programming
    Replies: 9
    Last Post: 06-22-2004, 11:37 AM
  5. XML File Parsing
    By WebSnozz in forum C++ Programming
    Replies: 0
    Last Post: 04-21-2002, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21