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. Which XML classes to use?

Which XML classes to use?

Scheduled Pinned Locked Moved C#
xmlquestion
3 Posts 2 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.
  • L Offline
    L Offline
    Lord Kixdemp
    wrote on last edited by
    #1

    Hello everyone! :-D Hey, how should I read and write to XML files? Some tutorials use XmlDocument, and some use XmlTextReader/Writer... I don't get it... Thanks! ;)

    Windows Calculator told me I will die at 28. :(

    P 1 Reply Last reply
    0
    • L Lord Kixdemp

      Hello everyone! :-D Hey, how should I read and write to XML files? Some tutorials use XmlDocument, and some use XmlTextReader/Writer... I don't get it... Thanks! ;)

      Windows Calculator told me I will die at 28. :(

      P Offline
      P Offline
      Phillip M Hoff
      wrote on last edited by
      #2

      The answer is: it depends! Both XmlDocument and XmlTextReader/Writer are perfectly valid ways to read and write XML files. The reasons for choosing one or the other depend on how the application intends to use the XML files. XmlDocument allows one to add or query XML nodes at random. To do so, it has to load the entire document before it can be used and keep the document in memory. On the other hand, XmlTextReader/Writer are forward-only reader/writers. That is, they visit each node sequentially in a stream-like manner. This makes the classes very fast and light on memory, but at the cost of more limited capabilities and being somewhat more difficult to use. I often find myself using a combination of the two in my applications: XmlDocument to read and extract data from XML documents (because it's easy and flexible) and XmlTextWriter to write XML documents (because it's easy and fast). -Phil

      L 1 Reply Last reply
      0
      • P Phillip M Hoff

        The answer is: it depends! Both XmlDocument and XmlTextReader/Writer are perfectly valid ways to read and write XML files. The reasons for choosing one or the other depend on how the application intends to use the XML files. XmlDocument allows one to add or query XML nodes at random. To do so, it has to load the entire document before it can be used and keep the document in memory. On the other hand, XmlTextReader/Writer are forward-only reader/writers. That is, they visit each node sequentially in a stream-like manner. This makes the classes very fast and light on memory, but at the cost of more limited capabilities and being somewhat more difficult to use. I often find myself using a combination of the two in my applications: XmlDocument to read and extract data from XML documents (because it's easy and flexible) and XmlTextWriter to write XML documents (because it's easy and fast). -Phil

        L Offline
        L Offline
        Lord Kixdemp
        wrote on last edited by
        #3

        Oh, OK, thanks! ;)

        Windows Calculator told me I will die at 28. :(

        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