Using NSXMLNode, NSXMLElement, and NSXMLDocument?

Discussion in 'iOS Programming' started by ace2600, Jul 15, 2008.

  1. macrumors member

    Mar 16, 2008
    Austin, Texas
    I built my app for the device today and get errors around NSXMLNode, NSXMLElement, and NSXMLDocument. Those were recognized fine in the simulator. Any ideas?

    Here is a post by someone else with a similar problem (but in the Mac Programming forum):
  2. thread starter macrumors member

    Mar 16, 2008
    Austin, Texas
  3. macrumors newbie

    Jun 20, 2008
    Phoenix, AZ
    TouchXML is pretty slick. I found it to be an adequate replacement for NSXMLDocument. It's read-only: there's no serialization behaviors defined. It uses libxml2, so it should be nice and quick.

    Otherwise, the recent releases included NSXMLParser, which might work for you if you just need a forward-only XML reader. It uses callbacks to notify your app about parsing milestones as it goes through the document.

  4. macrumors regular

    Mar 24, 2008
    NSXMLParser seems like a pretty useless class to me.

    All it seems to be is bunch of HARD CODED if-else statements of comparing the element names.

    My app originally used NSXMLDocument to receive xml response data that I looped through to fill up some NSDictionary's so I could put them inside UITableView -> Detail view.

    I pretty much need to loop through the entire xml data set, which has at least 50 elements. If I were to use NSXMLParser, would I be expected to write

    if ([element name isEqualToString:mad:"firstname"] {
    currentString = [NSMutableString string];
    } else if ...

    50 times for both "didStartEelement" and "didEndElement"? Sounds pretty ridiculous to me. Correct me if I'm wrong.
  5. macrumors member


    Jul 12, 2008
    You can use libxml2. That's what I do.
    It's C only (not C++ or obj-c) so you have to manage memory carefully, but in return you get real DOM.

Share This Page