English 中文(简体)
如何将当地储存的XML档案存放在Pi?
原标题:How to parse a locally stored XML file in iPhone?
  • 时间:2010-08-05 05:46:47
  •  标签:
  • iphone

如何将当地储存的XML档案存放在Pi?

请帮助我使用密码刀具。

问题回答

我使用了NSXMLParser,一度实现了。 我的资料来源是Xml。 我只用NSXMLParser标出名称。

      r.xml:

      <rss>
      <eletitle > My Xml Program  </eletitle>
      </rss>

我的样本代码是:

@interface:

  NSXMLParser *rssparser;

  NSMutableArray *stories;
  NSMutableDictionary *item;
  NSMutableString *currrentTitle;
  NSString *currentElement;

@implementation:

    -(void) viewDidAppear:(BOOL) animated
     {
           [self parseXMLFileAtURL];
     }

     -(void) parseXMLFileAtURL 
     {
         stories = [[NSMutableArray alloc] init];

         NSURL *xmlURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"r" ofType:@"xml"]];
         rssparser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
        [rssparser setDelegate:self];
        [rssparser setShouldProcessNamespaces:NO];
        [rssparser setShouldReportNamespacePrefixes:NO];
        [rssparser setShouldResolveExternalEntities:NO];
        [rssparser parse];

    }

    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ 

     currentElement = [elementName copy];
     if([elementName isEqualToString:@"rss"]);
     {
         item = [[NSMutableDictionary alloc] init];
         currrentTitle = [[NSMutableString alloc] init];
     }
 }


    -(void) parser:(NSXMLParser *)parser foundCharacters:(NSString *) string
     {
            if([currentElement isEqualToString:@"eletitle"])
            {
                 [currrentTitle appendString:string];
            }
      }

      - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ 

      if([elementName isEqualToString:@"rss"])
      {
             [item setObject:currrentTitle forKey:@"eletitle"];
             [stories addObject:[item copy]];
      }
   }

     - (void)parserDidEndDocument:(NSXMLParser *)parser
     {
              NSLog(@"The currrentTitle is %@",currrentTitle);

     }

Best of Luck.

我现在不能给你任何狙击手,但在我一段时间前所做的一个项目中,我们使用了触角图书馆。

http://code.google.com/p/touchcode/wiki/TouchXML”rel=“nofollow noreferer” http://code.google.com/p/touchcode/wiki/TouchXML

与此相对照,XML教区非常容易。

亲爱!





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签