I’m trying to get hold of data from a NSXMLParser
I have the following XML Sample Data:
<myCourse>
<courseName>BEng Mobile and Web Computing</courseName>
<courseStructure>
<level4>
<module>
<moduleCode>ECSC401</moduleCode>
<moduleTitle>Programming Methodology</moduleTitle>
<credits>15</credits>
<semester>1</semester>
<assessmentDetails>
<assessment>
<assessmentName>Test1</assessmentName>
<assessmentType>Coursework</assessmentType>
<assessmentWeighting>30</assessmentWeighting>
<assessmentDueDate/>
</assessment>
<assessment>
<assessmentName>Coursework</assessmentName>
<assessmentType>Coursework</assessmentType>
<assessmentWeighting>40</assessmentWeighting>
<assessmentDueDate/>
</assessment>
<assessment>
<assessmentName>Test2</assessmentName>
<assessmentType>Coursework</assessmentType>
<assessmentWeighting>30</assessmentWeighting>
<assessmentDueDate/>
</assessment>
</assessmentDetails>
</module>
</level4>
</courseStructure>
</myCourse>
And I have created the two Entity classes:
Module.h
@interface Module : NSObject {
NSString *moduleCode;
NSString *moduleTitle;
NSString *credits;
NSString *semester;
}
AssessmentDetail.h
@interface AssessmentDetail : NSObject {
NSString *assessmentName;
NSString *assessmentType;
NSString *assessmentWeighting;
NSString *assessmentDueDate;
}
That’s all I have really, I would like to be able to parse the XML data into an array to be implemented into a UITableView.
Can anyone guide me or help me with a simple way to actually have data output?
Thanks a lot.
Dou you really want to use NSXMLParser? If not, I suggest to use TBXML. It’s really easy to use if you know the structure of your XML File. Start at this page to get the APIs: TBXML APIs
If you are familiar with Objective-c you’ll get this XML parsed in half an hour. 😉
Sandro Meier