mal*_*aba 3 xml cocoa-touch ios restkit
我有这样的XML:
<rss>
<channel>
<item>
<title>something</title>
<description>...</description>
<category>cooking</category>
<category>housing</category>
</item>
<item>
...
</item>
...
</channel>
</rss>
Run Code Online (Sandbox Code Playgroud)
它是一个RSS Feed,在一个频道内有一系列项目,包含许多标签/属性(标题,内容,......),以及一组类别标签.
我可以使用RestKit为频道/项目/标题/内容部分解析它:
RKManagedObjectMapping *itemMapping = [RKManagedObjectMapping mappingForClass:[Item class] inManagedObjectStore:objectStore];
[itemMapping mapKeyPath:@"title" toAttribute:@"title"];
[itemMapping mapKeyPath:@"description" toAttribute:@"content"];
RKManagedObjectMapping *channelMapping = [RKManagedObjectMapping mappingForClass:[Channel class] inManagedObjectStore:objectStore];
[channelMapping mapKeyPath:@"item" toRelationship:@"items" withMapping:itemMapping];
[manager.mappingProvider setMapping:channelMapping forKeyPath:@"rss.channel"];
Run Code Online (Sandbox Code Playgroud)
但我迷失了地图类别......我尝试过类似的东西:
RKManagedObjectMapping *categoryMapping = [RKManagedObjectMapping mappingForClass:[Category class] inManagedObjectStore:objectStore];
[itemMapping mapKeyPath:@"category" toRelationship:@"categories" withMapping:CategoryMapping]
Run Code Online (Sandbox Code Playgroud)
但不知何故,标签内的文本内容未映射到Category类中的属性'name'.我肯定没有在这里的代码中使用这个"名称",因为我不知道在哪里放它.
如何使用RestKit解析纯文本XML标记?是否有类似的东西:
[categoryMapping mapKeyPath:@".text" toAttribute:@"name"];
Run Code Online (Sandbox Code Playgroud)
?
(不起作用)
归档时间: |
|
查看次数: |
1522 次 |
最近记录: |