1

XML ファイルを解析しています。すべてが完璧で、 でファイルが表示されていますNSLog。解析の結果も表示されていますが、必要なタグを に転送するNSMutableArrayと、結果が奇妙になります。

-(void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName

 namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qName {
    if ([elementName isEqualToString:@"nom"]) {
        // displays the Content of the tag
        NSLog(soapResults);
        // add the content of the tag to the NSMutableArray
        [mySuppliers addObject:soapResults];
        // displays the NSMutable Array
        NSLog(@"array: %@", mySuppliers);
        [soapResults setString:@""];
        elementFound = FALSE;
        // displays the count of the NSMutable Array
        NSLog(@"NUMBER %d", [mySuppliers count]);
 }
 ....

出力は次のとおりです。

2012-12-16 22:00:03.140 StartProj[11698:c07] ABC
2012-12-16 22:00:03.140 StartProj[11698:c07] array: (
    "ABC"
)
2012-12-16 22:00:03.140 StartProj[11698:c07] NUMBER 1
2012-12-16 22:00:03.141 StartProj[11698:c07] ABBOTT
2012-12-16 22:00:03.141 StartProj[11698:c07] array: (
    "ABBOTT ",
    "ABBOTT "
)
2012-12-16 22:00:03.141 StartProj[11698:c07] NUMBER 2
2012-12-16 22:00:03.142 StartProj[11698:c07] ACCESSORIES
2012-12-16 22:00:03.142 StartProj[11698:c07] array: (
    ACCESSORIES,
    ACCESSORIES,
    ACCESSORIES
)
2012-12-16 22:00:03.142 StartProj[11698:c07] NUMBER 3
4

2 に答える 2

1

xml の解析には、非常にシンプルな rapturexml を使用してみてください。

https://github.com/ZaBlanc/RaptureXML

于 2012-12-17T10:00:21.643 に答える
0

すべての要素を辞書に追加した後、NSmutabledictionary をより適切に割り当てることができます。最終的に辞書項目は nsmutable 配列にシフトします。 ここに画像の説明を入力

ここに画像の説明を入力

ここに画像の説明を入力

于 2012-12-17T05:20:46.513 に答える