table | hi | there |
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