table | hi | there |

* row 2
row 3  

Comparing strings

NSString* str ;
if (str isEqualToString: @"ExportPath"]) { // match }

Load a file, parse an XML file

   NSFileManager *nsfm = [NSFileManager defaultManager];
   if ([nsfm isReadableFileAtPath: path])
   {
      NSData *fileData = [NSData dataWithContentsOfFile: path]; 
      if (fileData != nil)
      {
         NSError *err = nil;
         
         NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:fileData 
             options:(NSXMLNodePreserveWhitespace|NSXMLNodePreserveCDATA) error:&err];
         {
            NSXMLNode* aNode = [xmlDoc rootElement];
            BOOL isdir = true;
            while (aNode = [aNode nextNode]) 
            {
               if ([[aNode name] isEqualToString: @"ExportPath"] && [aNode childCount] >=1)
               {
                  NSString* tmp = [[[aNode children] objectAtIndex:0] stringValue];
                  if ([nsfm fileExistsAtPath:tmp isDirectory: &isdir ])
                  {   exportPath = tmp;
                  }
               }               
               if ([[aNode name] isEqualToString: @"AudioFilePath"] && [aNode childCount] >=1)
               {
                  NSString* tmp = [[[aNode children] objectAtIndex:0] stringValue];
                  if ([nsfm fileExistsAtPath:tmp isDirectory: &isdir ])
                  {   audioFilePath = tmp;
                  }                  
               }                              
            }
         }
      }
   }

-- MattWalsh - 05 Jun 2010

Topic revision: r2 - 02 Jul 2011 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback