CSV format versus XMLParsing

Discussion in 'iOS Programming' started by MACloop, Mar 18, 2010.

  1. MACloop macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #1
    Hi,
    I have been using the NSXMLParser class in order to get and handle data for my apps. In my next project, I have total control over the data-setup and it could be possible to get it in xml or csv format. As I never used csv in combination with iphone-app-development, I thought I rather ask if anyone has experience from using csv in iphone-apps? Is it possible at all?

    Interesting is:
    - which one is the fastest - csv or xml parsing?
    - which one is the most robust/reliable to use - csv or xml parsing?
    - is there an api for csv parsing? I did not find such an api...
    - pros and cons generally...

    Any ideas or advices?
    Thanks in advance!
    MACloop
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    No. You would have to deal with all the parsing yourself. This alone will probably make XML the more attractive choice.
     
  3. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #3
    Ok, that is no option! Then I will use the xml parser. I only was curious in order to make the data-handling-process as good as possible. Thanks for you comment!
    MACloop
     
  4. rev316 macrumors regular

    Joined:
    Nov 7, 2004
    #4
    One isn't necessarily faster, it purely depends on your traversing algorithms.

    XML:

    The ability to validate XML makes it more "reliable".
    You can easily create contracts for an other parties consumption.
    XML is widely supported (lots of nice libs out there for you).
    XML is arguably more readable.

    CSV:

    If you don't have self-describing data, CSV is useful. Such as tabular data without multiple levels of relationships everywhere.
    It's lightweight.


    In short - stick with XML. You'll have a decent shot of thanking me later. :)
     
  5. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #5
    Thanks alot for the comment and the interesting information! Yea - I'll stick with XML :)
     
  6. AndyCodez macrumors regular

    Joined:
    Aug 6, 2009
    #6
    I would say it depends on what kind of data your looking to pull in. For my application I pull in cards as a csv, with either , or \t seperator. But I do know that I only accept a certain format. But if you are trying to pull in specific information, I would go with XML Which I use in many of my API Calls :)
     
  7. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #7
    Another fairly standard option is to use JSON formatted data. There are several JSON to Cocoa datatype bridges/converters available, and you can more easily test your server and data using just a browser.
     
  8. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #8
    Ok, that is cool - do you have a link for some more information on that?
    Thanks in advance!
    MACloop
     
  9. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #9
    Google keyword: JSON
     
  10. AndyCodez macrumors regular

    Joined:
    Aug 6, 2009
    #10
    I found an open source JSON Parser, but I'm at work and I cannot think of the name of it. I'll post it tonight if no here knows what it is.
     
  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  12. rev316 macrumors regular

    Joined:
    Nov 7, 2004
    #13
    If you don't need validation, use JSON. It's defiantly faster.
     
  13. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany

Share This Page