• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: TBXML question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TBXML question


  • Subject: Re: TBXML question
  • From: Philip Vallone <email@hidden>
  • Date: Fri, 13 Jan 2012 20:16:38 -0500

Hi Eric,

Have you considered using Libxml and xpath? Take a look at http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html.

Phil


On Jan 13, 2012, at 9:23 AM, Eric E. Dolecki wrote:

> I have XML like this:
>
> <xml version="1.0" encoding="UTF-8"?>
> <users>
>    <user name="Eric Dolecki">
>        <playlist name="Iron Maiden" source="Spotify"/>
>        <playlist name="Kate Bush" source="Pandora"/>
>    </user>
> </users>
>
> I am trying pull out the name and then each of the playlists. I need help
> with my while loop (to get all the playlists) - I've bolded that bit.
>
> - (void)parseThatXML:(TBXMLElement *)element {
>
>    do {
>
>        if(element -> firstChild)
>
>            [self parseThatXML:element -> firstChild];
>
>        if([[TBXML elementName:element] isEqualToString:@"user"]){
>
>            NSString *userName = [TBXML valueOfAttributeNamed:@"name"
> forElement:element];
>
>            NSLog(@"user: %@", userName);
>
>          *  TBXMLElement *playlist = [TBXML childElementNamed:@"playlist"
> parentElement:element];*
>
> *            while (playlist != nil) {*
>
> *                NSLog(@"%@", [TBXML valueOfAttributeNamed:@"name"
> forElement:playlist]); //infinite loop. how loop through all the playlists
> for the user?*
>
> *            }            *
>
>            //TBXMLElement *playlist = [TBXML childElementNamed:@"playlist"
> parentElement:element];
>
>            //NSLog(@"%@", [TBXML valueOfAttributeNamed:@"name"
> forElement:playlist]);
>
>        }
>
>    } while ((element = element -> nextSibling));
>
> }
>
>
>
>
>
>
>  Google Voice: (508) 656-0622
>  Twitter: eric_dolecki      XBoxLive: edolecki      PSN: eric_dolecki
>  http://blog.ericd.net
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: TBXML question
      • From: Jens Alfke <email@hidden>
References: 
 >TBXML question (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: Child windows appear to move when entering full-screen mode / how to detect full-screen transition
  • Next by Date: Re: TBXML question
  • Previous by thread: TBXML question
  • Next by thread: Re: TBXML question
  • Index(es):
    • Date
    • Thread