Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

webznz

macrumors member
Original poster
Mar 8, 2011
82
0
Hobbitin
Hey guys, I have been trying to parse some xml that have attributes and elements.. I have parsed xml with only element but not xml with both..

The XML I am trying to parse looks like this

Code:
<Rows>
    <Row SKATERID="706" MANUFACTURER="GAZ" ISFACT="F" ISSKATE="F"/>
    <Row SKATERID="318" MANUFACTURER="MAN" ISFACT="F" ISSKATE="T"/>
    //...
 </Rows>


I know that I need to use NSXMLPArser delegate didStartElement and didEndElement... I am hoping you guys can show me some straight forward code examples to get me on my way.
 

Sykte

macrumors regular
Aug 26, 2010
223
0
Hey guys, I have been trying to parse some xml that have attributes and elements.. I have parsed xml with only element but not xml with both..

The XML I am trying to parse looks like this

Code:
<Rows>
    <Row SKATERID="706" MANUFACTURER="GAZ" ISFACT="F" ISSKATE="F"/>
    <Row SKATERID="318" MANUFACTURER="MAN" ISFACT="F" ISSKATE="T"/>
    //...
 </Rows>


I know that I need to use NSXMLPArser delegate didStartElement and didEndElement... I am hoping you guys can show me some straight forward code examples to get me on my way.

The delegate call back didStartElement passes a dictionary of attributes.
 

RonC

macrumors regular
Oct 18, 2007
108
0
Chicago-area
Hey guys, I have been trying to parse some xml that have attributes and elements.. I have parsed xml with only element but not xml with both..

The XML I am trying to parse looks like this

Code:
<Rows>
    <Row SKATERID="706" MANUFACTURER="GAZ" ISFACT="F" ISSKATE="F"/>
    <Row SKATERID="318" MANUFACTURER="MAN" ISFACT="F" ISSKATE="T"/>
    //...
 </Rows>


I know that I need to use NSXMLPArser delegate didStartElement and didEndElement... I am hoping you guys can show me some straight forward code examples to get me on my way.

You need to implement didStartElement and maybe didEndElement. I did all of the API in a utility class (RCXMLDictionary) that I use as a base class for a bunch of more specific XML format - turned out that solving the XML parser interface once was easier for me than trying to copy and solve it several times for each of those formats.

I'm working on posting it to github or sourceforge; when I do, I'll follow-up with a link.

Just a note: NSXMLParser seems to have a leak; it doesn't seem to be huge, but it does piss me off that my app leaks because the library leaks. All my leaks (other than NSXMLParser-generated ones) were found and eradicated.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.