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
  1. Home
  2. General Programming
  3. C#
  4. Working with 1GB XML file

Working with 1GB XML file

Scheduled Pinned Locked Moved C#
csssysadminxmlperformancequestion
4 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.
  • P Offline
    P Offline
    Praveen Raghuvanshi
    wrote on last edited by
    #1

    I have a client server application and i am writing messages from the client to the XML file. sometimes the files reaches 1GB. Operating such a large XML file creates lot of problems such as memory, time. there may be loss of data too. please suggest me a method to operate my file with less memory????? Thanks in advance...

    Praveen Raghuvanshi Software Engineer

    D P D 3 Replies Last reply
    0
    • P Praveen Raghuvanshi

      I have a client server application and i am writing messages from the client to the XML file. sometimes the files reaches 1GB. Operating such a large XML file creates lot of problems such as memory, time. there may be loss of data too. please suggest me a method to operate my file with less memory????? Thanks in advance...

      Praveen Raghuvanshi Software Engineer

      D Offline
      D Offline
      Daniel Grunwald
      wrote on last edited by
      #2

      XML is a bad choice handling large amounts of data. Use XmlTextReader and XmlTextWriter for reading/writing XML files. Do not use XmlDocument (it stores the whole document in RAM). Use XML only for import/export of data, store it inside a normal binary database for normal usage.

      1 Reply Last reply
      0
      • P Praveen Raghuvanshi

        I have a client server application and i am writing messages from the client to the XML file. sometimes the files reaches 1GB. Operating such a large XML file creates lot of problems such as memory, time. there may be loss of data too. please suggest me a method to operate my file with less memory????? Thanks in advance...

        Praveen Raghuvanshi Software Engineer

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        If your XML file is getting that big, then there seems to be an architectural problem here. Have you considered using a database instead (much better suited to things like this). Alternatively, you may want to consider SAX (Simple API for XML) which is an event based rather than tree based API. See http://saxdotnet.sourceforge.net/index.html[^]

        the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
        Deja View - the feeling that you've seen this post before.

        1 Reply Last reply
        0
        • P Praveen Raghuvanshi

          I have a client server application and i am writing messages from the client to the XML file. sometimes the files reaches 1GB. Operating such a large XML file creates lot of problems such as memory, time. there may be loss of data too. please suggest me a method to operate my file with less memory????? Thanks in advance...

          Praveen Raghuvanshi Software Engineer

          D Offline
          D Offline
          donchev_p
          wrote on last edited by
          #4

          I think you should consider to use the SAX approach. XmlDocument uses DOM and the whole document is loaded into the memory (as mentioned above). The SAX approach takes parts of the document only, which may be your solution... SAX is stream based and the stream is bi-directional. Which means you can write and read. It uses events. Unfortunately I can't help you about the .NET implementation of SAX. I don't know if there is any ... You may search for the MSXML (Microsoft XML Core Services). I think this is available as COM object. You also may want to see the following page : http://sourceforge.net/projects/saxdotnet[^] Hope it helps. P.S. if you find a solution to this problem - please drop us a line ...

          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