开发者

XML file Parsing?

I have a xml file in following format.

&l开发者_如何学JAVAt;Category id="CIBA_VISION" image="Choose_Page\CON_PNG\Ciba_Vision.png">
    <Product id="CON_CIBA_01" image="Buy_Page\Eye_CON_PNG\CIBAVision\List_01.png">
        <Detail image="Buy_Page\Eye_CON_PNG\CIBAVision\Buy_01.png"/>
    </Product>

where images contains image path in specified folder which is in resource folder of project.

My question is: After parsing this xml file, will the image tag pick the values from the folder or it will show only path after parsing.

Thanks in advance.


NSString *imaegeString = @"Ciba_Vision.png";
NSArray *pathComponents = [imaegeString componentsSeparatedByString:@"_"];
NSString *imageName=[pathComponents lastObject];
UIImage *img8 = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:imageName]];

try this code


It will only contain the values you see there, except you add the base to URLs while parsing yourself.

And picking completely depends on your context, how do you like the code to pick?


yes you can get the image by the following code in your imageView You can try this:-

 NSString *imaegeString = @"Choose_Page\CON_PNG\Ciba_Vision.png";
    NSArray *pathComponents = [imaegeString componentsSeparatedByString:@"_"];
    NSString *imageName=[pathComponents lastObject];
    UIImage *img8 = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:imageName]];

Hope this might help you...If this work you can do same for another strings in your parsing...


you ll get only path after parsing it wont do anything with that path.we have use that path and do our work thats it

some sample is

  -(void)parser:(NSXMLParser *)parser 
didStartElement:(NSString *)elementName 
   namespaceURI:(NSString *)namespaceURI 
  qualifiedName:(NSString *)qName 
     attributes:(NSDictionary *)attributeDict
{
    if([elementName isEqualToString: @"Detail"]){
       //get all the attributes of from the dictionary(attributeDict)

    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜