mercredi 29 juin 2016

What’s your favorite xml parser for parse my XML file in Objective-C [on hold]

What’s your favorite xml parser in Objective-C

I develop an app in Objective C , i need to parse this XML file for get the data of Fuel Price

here an example of my XML file

thanks for you help

<pdv id="1000001" latitude="4620114" longitude="519791" cp="01000" pop="R">
<adresse>ROUTE NATIONALE</adresse>
<ville>SAINT-DENIS-LèS-BOURG</ville>
<ouverture debut="01:00" fin="01:00" saufjour=""/>
<services>
<service>Automate CB</service>
<service>Vente de gaz domestique</service>
<service>Station de gonflage</service>
</services>
<prix nom="Gazole" id="1" maj="2014-01-02 11:08:03" valeur="1304"/>
<prix nom="SP98" id="6" maj="2014-12-31 08:39:46" valeur="1285"/>
<prix nom="Gazole" id="1" maj="2007-02-28 07:48:59.315736" valeur="999"/>
<fermeture/>
<rupture/> 
</pdv> 

I try to make this code below and i need your help for parse the Rows of my Xml file

    NSXMLParser *xmlparser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"my url file"]];XML"]];
    [xmlparser setDelegate:self];
    [xmlparser parse];
    if (marrXMLData.count != 0) {
        [self.tableView reloadData];
    }
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict;
{
    if([elementName isEqualToString:@"pdv_liste"])
        marrXMLData = [[NSMutableArray alloc] init];
    if([elementName isEqualToString:@"pdv"])
        mdictXMLPart = [[NSMutableDictionary alloc] init];
}

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire