How do you parse with SAX using Attributes & Values to a URL path using iPhone SDK?

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2009-09-07T22:10:01Z Indexed on 2010/05/11 2:04 UTC
Read the original article Hit count: 277

Filed under:
|
|
|

I'm trying to get my head around parsing with SAX and thought a good place to start was the TopSongs example found at the iPhone Dev Center. I get most of it but when it comes to reaching Attributes and Values within a node I can't find a good example anywhere. The XML has a path to a URL for the coverArt. And the XML node looks like this.

<itms:coverArt height="60" width="60">http://a1.phobos.apple.com/us/r1000/026/Music/aa/aa/27/mzi.pbxnbfvw.60x60-50.jpg</itms:coverArt>

What I've tried is this for the startElement…

 ((prefix != NULL && !strncmp((const char *)prefix, kName_Itms, kLength_Itms)) && 
        (!strncmp((const char *)localname, kName_CoverArt, kLength_Item) &&
         !strncmp((const char *)attributes, kAttributeName_CoverArt, kAttributeLength_CoverArt) &&
         !strncmp((const char *)attributes, kValueName_CoverArt, kValueLength_CoverArt) ||
         !strncmp((const char *)localname, kName_Artist, kLength_Artist) ||

and picking it up again with just the localname at the end like this.

if (!strncmp((const char *)localname, kName_CoverArt, kLength_CoverArt)) { importer.currentSong.coverArt = [NSURL URLWithString:importer.currentString];

The trace is -[Song setCoverArt:]: unrecognized selector sent to instance.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about saxparser