developer.apple.com からではなく、XCode に SAX XML パーサーの例のリンクを投稿できますか。この XML ファイルを解析する必要があります。
<?xml version="1.0" encoding="UTF-8"?>
<userfood_overview xmlns="http://www.wikifood.lu" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wikifood.lu userfood.xsd">
<hits>1</hits>
<startAt>0</startAt>
<userfood>
<id>770</id>
<ean>4016249502058 </ean>
<name><![CDATA[Amaranth-Früchte-Müsli / Großpackung]]></name>
<modification>2012-10-09</modification>
<info1><![CDATA[Amaranth - Müsli mit Früchten]]></info1>
<origin id="55">Germany</origin>
<brand>
<id>155</id>
<name><![CDATA[Allos]]></name>
</brand>
<contents><![CDATA[1,5]]></contents>
<unit id="8">Kilogram</unit>
<nutrition_facts>
<nutrition_fact id="Per_100_g_ml">
<name>per 100</name>
<value>g</value>
<unit/>
</nutrition_fact>
<nutrition_fact id="EnergyKcal">
<name>Energy kcal</name>
<value>377</value>
<unit>kcal</unit>
</nutrition_fact>
<nutrition_fact id="EnergyKjoule">
<name>Energy kj</name>
<value>1580</value>
<unit>kj</unit>
</nutrition_fact>
</nutrition_facts>
<allergens>
<allergen id="774"><![CDATA[Nuts]]></allergen>
<allergen id="773"><![CDATA[Milk (including lactose)]]></allergen>
<allergen id="777"><![CDATA[Sesame seeds]]></allergen>
<allergen id="782"><![CDATA[Gluten]]></allergen>
<allergen id="772"><![CDATA[Soy]]></allergen>
</allergens>
<food_notes/>
<category id="0602003" delimiter=":"><![CDATA[Muesli]]></category>
<insertion>2007-01-16</insertion>
<editable>false</editable>
</userfood>
</userfood_overview>
、しかしhttp://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/XMLParsing/Articles/UsingParser.html#//apple_ref/doc/uid/20002264-BCIIJEEHのドキュメントからはわかりません. これは私が持っているものです:
#pragma mark *** NSXMLParserDelegate ***
- (void)parserDidStartDocument:(NSXMLParser *)parser
{
// do preparation for loading data from XML
}
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
[parser release];
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
//analyze parseError
[parser release];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
NSLog(@"elementName %@", elementName); // current parsing element
// specify type of data to be saved in method below
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
NSLog(@"value of element %@", string); // value for current parsing element
// save data to some ivar for future use (displaying)
}
ありがとう。