Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. XML Parsing on the fly

XML Parsing on the fly

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresxmljsonperformancequestion
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    topus
    wrote on last edited by
    #1

    I found many libraries that parsing XML files but all of this use a standard approacing. Read the entire file in memory and parsing the tree. This is very expensive if the file is very big or if you lock far a minimal set of informations (for intance, suppose to check if in a 50Mb XML file exist a reference to a user "Donal Duck" ecc). Any people know a "parsing on the fly" library or class that parse a XML file but don't load the entire file in memory? Thanks in advance and sorry for the poor english

    K P 2 Replies Last reply
    0
    • T topus

      I found many libraries that parsing XML files but all of this use a standard approacing. Read the entire file in memory and parsing the tree. This is very expensive if the file is very big or if you lock far a minimal set of informations (for intance, suppose to check if in a 50Mb XML file exist a reference to a user "Donal Duck" ecc). Any people know a "parsing on the fly" library or class that parse a XML file but don't load the entire file in memory? Thanks in advance and sorry for the poor english

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      Use the SAX API. The samples/libraries you have been looking at appearantly uses DOM. Kakan

      L T 2 Replies Last reply
      0
      • K kakan

        Use the SAX API. The samples/libraries you have been looking at appearantly uses DOM. Kakan

        L Offline
        L Offline
        lemur2
        wrote on last edited by
        #3

        To be more specific, you want to find a parser that *supports* the SAX API. It isn't SAX exactly, but James Clark's expat supports a similar interface and is one of the earliest and IMO still one of the best XML parsers around. It's certainly very easy to use. You can get this on sourceforge. Kev

        K 1 Reply Last reply
        0
        • T topus

          I found many libraries that parsing XML files but all of this use a standard approacing. Read the entire file in memory and parsing the tree. This is very expensive if the file is very big or if you lock far a minimal set of informations (for intance, suppose to check if in a 50Mb XML file exist a reference to a user "Donal Duck" ecc). Any people know a "parsing on the fly" library or class that parse a XML file but don't load the entire file in memory? Thanks in advance and sorry for the poor english

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          I think MSXML supports both SAX and DOM way of parseing the xml file. It would be good thing to use unless you dont want to use COM in your application.


          -Prakash

          K 1 Reply Last reply
          0
          • L lemur2

            To be more specific, you want to find a parser that *supports* the SAX API. It isn't SAX exactly, but James Clark's expat supports a similar interface and is one of the earliest and IMO still one of the best XML parsers around. It's certainly very easy to use. You can get this on sourceforge. Kev

            K Offline
            K Offline
            kakan
            wrote on last edited by
            #5

            lemur2 wrote:

            To be more specific, you want to find a parser that *supports* the SAX API.

            Well... It's pretty hard to to use the SAX API (as I suggested), if the parser in question doesn't support it :laugh:

            L 1 Reply Last reply
            0
            • P Prakash Nadar

              I think MSXML supports both SAX and DOM way of parseing the xml file. It would be good thing to use unless you dont want to use COM in your application.


              -Prakash

              K Offline
              K Offline
              kakan
              wrote on last edited by
              #6

              Yes, it does.

              P 1 Reply Last reply
              0
              • K kakan

                Yes, it does.

                P Offline
                P Offline
                Prakash Nadar
                wrote on last edited by
                #7

                kakan wrote:

                Yes, it does.

                thanx :->:->


                -Prakash

                1 Reply Last reply
                0
                • K kakan

                  lemur2 wrote:

                  To be more specific, you want to find a parser that *supports* the SAX API.

                  Well... It's pretty hard to to use the SAX API (as I suggested), if the parser in question doesn't support it :laugh:

                  L Offline
                  L Offline
                  lemur2
                  wrote on last edited by
                  #8

                  kakan wrote:

                  Well... It's pretty hard to to use the SAX API (as I suggested), if the parser in question doesn't support it

                  Oops, sorry - slipped into work document-reviewing-mode. Comment still stands though ;) K

                  1 Reply Last reply
                  0
                  • K kakan

                    Use the SAX API. The samples/libraries you have been looking at appearantly uses DOM. Kakan

                    T Offline
                    T Offline
                    topus
                    wrote on last edited by
                    #9

                    I looking for a library working like: ParseXMLFile(file...,callback ) { while( scanning file...){ ..... callback.OnEnterNode( nodeName, attributes...) .... .. processing XML formatting... .... callback.OnExitNode( nodeName ) } }

                    K 1 Reply Last reply
                    0
                    • T topus

                      I looking for a library working like: ParseXMLFile(file...,callback ) { while( scanning file...){ ..... callback.OnEnterNode( nodeName, attributes...) .... .. processing XML formatting... .... callback.OnExitNode( nodeName ) } }

                      K Offline
                      K Offline
                      kakan
                      wrote on last edited by
                      #10

                      That's what (a parser with a) SAX-api does! You register callbacks for the events you are interested of. Then you call the parse() function in the parser, and it calls your callback functions when appropriate. And it does this "on the fly", that is: while it's reading the XML file. So it's exacly what you want! You might be interested in checking MSXML out. It has got a SAX API. There are heaps of samples how to use SAX on MSXML. Kakan

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups