我有這樣的XML:如何使用RestKit映射XML textContent?
<rss>
<channel>
<item>
<title>something</title>
<description>...</description>
<category>cooking</category>
<category>housing</category>
</item>
<item>
...
</item>
...
</channel>
</rss>
這是一個RSS源,具有通道內項目的數組,包含許多標籤/屬性(標題,內容,...),與類別的集合標籤。
我可以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"];
但我在失去了測繪類...我已經試過類似的東西:
RKManagedObjectMapping *categoryMapping = [RKManagedObjectMapping mappingForClass:[Category class] inManagedObjectStore:objectStore];
[itemMapping mapKeyPath:@"category" toRelationship:@"categories" withMapping:CategoryMapping]
但不知怎的,標籤內的文本內容未映射到Category類中的屬性「名稱」。當然,我沒有在代碼中使用這個'名字',因爲我不知道該把它放在哪裏。
如何使用RestKit解析純文本XML標記?有沒有類似的東西:
[categoryMapping mapKeyPath:@".text" toAttribute:@"name"];
?
(不起作用原樣)
This is close [鏈接](http://stackoverflow.com/q/9196947/1040553) – malaba