• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Productaccess m
 

Productaccess m

on

  • 277 views

test

test

Statistics

Views

Total Views
277
Views on SlideShare
277
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Productaccess m Productaccess m Document Transcript

    • //// ProdAttributeAccess.m// Office//// Copyright (c) 2012 Sovoia. All rights reserved.////// ProdAttributeAccess.m// Office//// Created by SMonte Developer on 11/16/10.// Copyright 2010 __MyCompanyName__. All rights reserved.//#import "ProdAttributeAccess.h"//#import "ProdAttribute.h"@implementation ProdAttributeAccess@synthesize productLongDesc,productShortDesc,prodBrand;@synthesize displayURL, prodStyleCode, colourCode,prodWasPrice, prodColour,prodPrice, imgURLthumb, prodTitle, fullSkuNumber;- (id) init{ if(self = [super init]) { sizesArray = [[NSMutableArray alloc]init]; skuArray = [[NSMutableArray alloc]init]; found = YES; errorResponse = [[NSString alloc]initWithString:@""]; displayURL = [[NSString alloc]initWithString:@""]; prodBrand =[[NSString alloc]initWithString:@""]; prodStyleCode = [[NSString alloc]initWithString:@""]; colourCode =@""; prodColour = [[NSString alloc]initWithString:@""]; prodPrice = [[NSString alloc]initWithString:@""]; prodWasPrice = @""; prodTitle = [[NSString alloc]initWithString:@""]; imgURLthumb = [[NSString alloc]initWithString:@""]; fullSkuNumber = [[NSString alloc]initWithString:@""]; } return self;}- (BOOL)parseXMLFileAtURL:(NSString *)URL{ NSURL *xmlURL = [NSURL URLWithString:URL]; NSXMLParser*parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; [parser setDelegate:self]; [parser setShouldProcessNamespaces:YES]; [parser setShouldReportNamespacePrefixes:YES]; [parser setShouldResolveExternalEntities:NO]; BOOL success =[parser parse]; [parser release]; return success;}
    • - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementNamenamespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary*)attributeDict{ if(nil != qualifiedName){ elementName = qualifiedName; } if ([elementName isEqualToString:@"msg"]||[elementNameisEqualToString:@"Short_Description"] || [elementName isEqualToString:@"Long_Description"]||[elementNameisEqualToString:@"displayurl"] ||[elementName isEqualToString:@"title"]||[elementNameisEqualToString:@"imageurlthumb"] ||[elementName isEqualToString:@"retailprice"] || [elementNameisEqualToString:@"wasprice"] ||[elementName isEqualToString:@"STYLECODE"]||[elementNameisEqualToString:@"BRAND"]||[elementName isEqualToString:@"COLOUR"]|| [elementName isEqualToString:@"name"]) { productAttrNode = [NSMutableString string]; } else if([elementName isEqualToString:@"value"]) { productAttrNode = [NSMutableString string]; if ([attributeDict objectForKey:@"sku"]) { //skuValue = [NSMutableString stringWithString:[attributeDictobjectForKey:@"sku"]]; NSString *sku = [attributeDict objectForKey:@"sku"]; fullSkuNumber = sku; [skuArray addObject:sku]; // NSLog(@"Sku : %@",[attributeDict objectForKey:@"sku"]); } } else { productAttrNode = nil; }}- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementNamenamespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if(nil != qName){ elementName = qName; } if([elementName isEqualToString:@"msg"]) { errorResponse = productAttrNode; } else if([elementName isEqualToString:@"Short_Description"]) { productShortDesc = productAttrNode; } else if([elementName isEqualToString:@"Long_Description"]) { productLongDesc = productAttrNode; } else if([elementName isEqualToString:@"title"]) { // NSLog(@"title in XML: %@",productAttrNode);
    • prodTitle = productAttrNode;}else if([elementName isEqualToString:@"displayurl"]){ displayURL = productAttrNode;}else if([elementName isEqualToString:@"imageurlthumb"]){ imgURLthumb = productAttrNode;}else if([elementName isEqualToString:@"retailprice"]){ prodPrice = productAttrNode;}else if([elementName isEqualToString:@"wasprice"]){ prodWasPrice = productAttrNode;}else if([elementName isEqualToString:@"name"]){ if([productAttrNode isEqualToString:@"SIZE"]) { fullSkufound = YES; found = YES; } else { fullSkufound = NO; found = NO; } if([productAttrNode isEqualToString:@"STYLECODE"]) { styleCodeFound = YES; } else { styleCodeFound = NO; } if([productAttrNode isEqualToString:@"LEGACYCOLOURCODE"]) { colourCodeFound = YES; } else { colourCodeFound = NO; } if([productAttrNode isEqualToString:@"BRAND"]) { brandFound = YES; } else { brandFound = NO; } if([productAttrNode isEqualToString:@"COLOUR"]) { colourFound = YES; } else { colourFound = NO; } if([productAttrNode isEqualToString:@"Price"]) { priceFound = YES;
    • } else { priceFound = NO; } // if([productAttrNode isEqualToString:@"FULLSKU"]) // { // fullSkufound = YES; // } // else { // // fullSkufound = NO; // } } else if([elementName isEqualToString:@"value"]) { if(found) { [sizesArray addObject:productAttrNode]; // fullSkuNumber = skuValue; //[skuArray addObject:skuValue]; // NSLog(@"size array %@ n sky array %@",sizesArray,skuArray); } else if(styleCodeFound) { prodStyleCode = productAttrNode; } else if(colourCodeFound) { colourCode = productAttrNode; } else if(brandFound) { prodBrand = productAttrNode; } else if(colourFound) { prodColour = productAttrNode; } else if(priceFound) { prodPrice = productAttrNode; } /* else if(fullSkufound) { fullSkuNumber = skuValue; [skuArray addObject:skuValue]; //fullSkufound = NO; } */ } else if ([elementName isEqualToString:@"attribute"]) { /* [productAttrArray addObject:prodAttr]; [prodAttr release]; */ }}
    • /* - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if ([string isEqualToString:@"<"] || [string isEqualToString:@">"]) return; if(nil != productAttrNode){ } } */- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ //NSLog(@"found: %@",string); if ([string isEqualToString:@"<"] || [string isEqualToString:@">"]) return; if ([[string stringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]] length] ) { if(nil != productAttrNode) { [productAttrNode appendString:[stringstringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]]; } }}- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError{ NSLog(@"Error in Product Accsess Parser: %@", [parseError description] );}- (void)parserDidEndDocument:(NSXMLParser *)parser{}- (NSMutableArray*) getsizesArray{ return sizesArray;}- (NSMutableArray*) getSkuArray{ return skuArray;}-(NSString*)getErrorResponse{ return errorResponse;}-(NSString*)getProdBrand{ return prodBrand;}-(NSString*)getProdStyleCode{ return prodStyleCode;}-(NSString*)getColourCode{ return colourCode;}-(NSString*)getProdColour{ return prodColour;}-(NSString*)getProdPrice{ return prodPrice;
    • }-(NSString*)getProdWasPrice { return prodWasPrice;}-(NSString*)getProdTitle{ return prodTitle;}-(NSString*)getiImgURLthumb{ return imgURLthumb;}-(NSString*)getFullSkuNumber{ return fullSkuNumber;}-(NSString*)getDisplayURL{ return displayURL;}-(void)dealloc { [sizesArray release]; [skuArray release]; [super dealloc];}@end