CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009

    Unhappy Parsing XML in C# Dot Net

    Using VS2008, .net 3.5

    I'm working on an app that will potentially parse thousands of XML files. What I'm working on is actually a rewrite of a Java application that I've already written and has been in production for some time now. Everything I've read says that the .net implementation of DOM and SAX/pull parsing is slower than Java, but there performance hit that I'm seeing is ridiculous.

    In benchmarking tests that I've run with my previous Java implementation vs. two implementations of .net parsing are stark and disappointing. I'm hoping that I'm doing something wrong and that all the 50lb heads in this forum might be able to save the day. A benchmark I ran today had my Java implementation finish parsing at 15 seconds where my best .net implementation ran for 95 seconds.

    The two implementations I've tried include using

    1) ...xmlDoc.GetElementsByTagName(...) and a bunch of if statements to grab the nodes I'm looking for.

    2) using LINQ to query the xml file(s) for the info I need to grab.

    As you might assume, LINQ is the faster of the two implementations. I just started down a third route of trying XMLTextReader, and just reading through the entire file was still slow (that's not doing anything with the data).

    I've been searching the interwebs to no avail...Anybody have a definitive answer on what the FASTEST XML parsing implementation is? I'm open to third-party solutions as well. I'm at my wits end on this...


  2. #2
    Join Date
    May 2007

    Re: Parsing XML in C# Dot Net

    Everything I've read says that the .net implementation of DOM and SAX/pull parsing is slower than Java,
    http://msdn.microsoft.com/en-us/vstudio/aa700841.aspx. Don't believe everything you read, especially if it relates to older versions of the software you're using.

    If you want help you're going to have to show the C# and Java code you used for your fastest implementation. A 1.86ghz core2duo machine can chomp xml at a rate of > 76MB/sec using XmlReader. If you can't match that on similar hardware, something is going horribly wrong.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)