我知道它可能看起來像XML解析帖子的副本,但我真的不能理解節點和委託方法的行爲。我有一個XML ..如何使用帶有不同節點的NSXMLParser解析XML?
<?xml version="1.0" encoding="UTF-8"?>
<ParticipantService>
<Response>
<CourseProperties>
<CourseTitle>AICC_Flash_Workshop_PPT_to_web_examples</CourseTitle>
<CourseCode>123456</CourseCode>
<Availability>Open</Availability>
<Status>In Progress</Status>
<ImageLink>HTTP://lmsstaging.2xprime.com/images/inprogress_icon.png</ImageLink>
<CategoryCode>0</CategoryCode>
<CategoryDesc>General</CategoryDesc>
</CourseProperties>
<CourseProperties>
<CourseTitle>Behaviours</CourseTitle>
<CourseCode>OBIUS</CourseCode>
<Availability>Open</Availability>
<Status>In Progress</Status>
<ImageLink>HTTP://lmsstaging.2xprime.com/images/inprogress_icon.png</ImageLink>
<CategoryCode>0</CategoryCode>
<CategoryDesc>General</CategoryDesc>
</CourseProperties>
<CourseProperties>
<CourseTitle>Customer Service Skills (Part - one)</CourseTitle>
<CourseCode>css_1</CourseCode>
<Availability>Open</Availability>
<Status>In Progress</Status>
<ImageLink>HTTP://lmsstaging.2xprime.com/images/inprogress_icon.png</ImageLink>
<CategoryCode>0</CategoryCode>
<CategoryDesc>General</CategoryDesc>
</CourseProperties>
....
我的要求是,以存儲相關課程內容到相應的數組。所以我宣佈了6個nsmutablearray,但卻對如何從XMl中檢索數據感到困惑。我這樣
想出來的foundCharacters方法,我追加字符串的值作爲
videoUrlLink = [NSMutableString stringWithString:string];
和didEndElement方法
if ([elementName isEqualToString:@"CourseTitle"]) {
[courseDetailList addObject:string];
}
但在XML我能夠結束僅在數組中存儲一個值。請讓我知道我是否在某個地方出了問題?
在這種情況下如何從存儲的數據中檢索值?我的意思是如何獲得所有課程名稱,可用性,狀態e.t.c ....? –
你已經提到在didEndElement:方法中爲currentCourse添加字符串。但是在這個元素中,你將不會擁有字符串屬性。你可以檢查一下嗎? –