Need help Parsing xml file

Discussion in 'iOS Programming' started by Pietje321, Feb 2, 2009.

  1. Pietje321 macrumors newbie

    Feb 2, 2009

    I'm having trouble parsing a xml file correctly.
    I know the code for parsing a xml file like this one below:

    <book id="1">

    But my question is how can i parse a xml like this one:

    <book id="1">
    <title ="Naam"/>
    <author ="Auteur"/>
    <summary ="Samenvatting"/>

    Hope someone can help me with this.

    thanks in advance..
  2. jnic macrumors 6502a

    Oct 24, 2008
    I could be wrong but I'm pretty sure NSXMLParser handles self-closing tags correctly.
  3. Pietje321 thread starter macrumors newbie

    Feb 2, 2009
    Yes i now i can do it with the NSXMLPARSER but how can i do that precisly..

    can you show me some code so i can get underway..

    thanx in advance
  4. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    parser:didStartElement:namespaceURI:qualifiedName:attributes: should be able to pull in that info, normally, via the attributes parameter. But I suspect it may not work in your case, since I believe your XML is not well-formed; it will think it is either missing the tag name or the attribute key. Can you redo the tagging to be?:
    <title title="Naam"/>
    <author author ="Auteur"/>
    <summary summary ="Samenvatting"/>
    P.S. Are you Dutch by the way, Pietje?

Share This Page