TBXML - still used?

Discussion in 'iOS Programming' started by Tander, Aug 12, 2013.

  1. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #1
    Hi Guys,

    So, while deciding which XML Parser to use for my new project - I looked at this article:

    http://www.raywenderlich.com/553/xm...e-the-best-xml-parser-for-your-iphone-project

    However that article is over three years old. I also took a look at the official website:

    www.tbxml.co.uk

    It seems it hasn't been updated in a while, either.

    So, this leaves me with some questions:

    1. Is it still okay to use this library for parsing XML data?
    2. Should I worry that it hasn't been updated in a while?
    3. Is there something better?

    The reason I looked at TBXML is due to that Ray article I read - TBXML is light and fast - which is what I want for large XML document downloads.

    Thanks all
     
  2. Tander thread starter macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #2
  3. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    I always just use NSXMLParser. I've never had problems with it and I tend to stay away from using libraries / code written by other people.
     
  4. Tander thread starter macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #4
    Which would alleviate the question I was asking about, compatibility. However, I'm still in the early stages of my iOS development career and don't know enough about NSXMLParser to effectively use it on my own.

    If a library helps, then I think that's going to be the way forward.

    Having said that I am told I would need to write, many, many lines of code with NSXMLParser to get what TBXML does already?

    Secondly - my app will be downloading lots of XML documents - so, speed is important here, too.

    Would you suggest I take the time to learn NSXMLParser and just go with that?
     
  5. Tander thread starter macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #5
    Actually, the more I think about it the more I am leaning towards using Apple's own XML Parser as I know there will always be support, help and tutorials on how to use it. Where as a 3rd party library, there won't be.

    Thanks for the suggestion.

    I'm going to take the time to learn NSXMLParser - even if it takes me a week or two to learn.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    You might also want to consider using libxml2.
     
  7. mjohnson1212 macrumors member

    Joined:
    Nov 15, 2007
    #7
    Edit: Looks like dejo beat me to the submit button :)

    Remember with NSXMLParser it reads the whole doc into memory.

    You mentioned large XML files. Depending on what you mean by large you might not want to load the whole xml file in memory.

    libxml2 is a C lib that's part of the iOS SDK and it has a streaming api where you don't have to read the whole file into memory.

    Link to docs here:

    xmlsoft.org/index.html
     
  8. Tander thread starter macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #8
    From my understanding NSXMLparser is SAX based and this uses "events" while walking through the XML document - and thus doesn't save the document to memory?

    Or am I confusing this with a DOM Parser, which copies the whole document into memory?

    With the livxml2 library - I know it's included in the SDK - however it requires a lot more work since it's C based - so would have t wrap a lot fo the stuff with Objective-C code. I'm not sure if I am up for that sort of challenge, just yet?

    Any advantage to using that library over NSXMLParser?

    Thanks for the input guys.
     
  9. mjohnson1212 macrumors member

    Joined:
    Nov 15, 2007
    #9
    NSXMLParser does indeed load the whole file into memory before it sends the events.

    It is a SAX style parser. libxml2 also includes a DOM api as well as the reader (or stream) api.

    You can test it yourself. Get a large xml file and load it up with the NSXMLParser in Instruments and watch you're heap grow the size of the file.

    The advantage of using libxml2 is you don't have to read the whole file into ram.
     
  10. Tander thread starter macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #10
    Well, I think the best way forward would be testing these files with each version of XML Parser and just see how bad it gets. When I say they are large.. they are not that large in size. Most of them is text and images - that's all really.

    Thank you for your input
     

Share This Page