Reputation: 1069
I'm new to iOS development. I've found RaptureXML and it works quiet well but I could not load data which I stored in my user directory. Having a "data.xml" within my application directory works fine, I could load it with [RXMLElement elementFromXMLFile:@"data.xml"];
. But now I have downloaded a file from Internet and stored it in my user directory using these lines:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"data.xml"];
The computed file path is
"/Users/myname/Library/Application Support/iPhone Simulator/6.0/Applications/myapplicationguid/Documents/data.xml"
.
The file exists, I've checked with [[NSFileManager defaultManager] fileExistsAtPath:filename];
. I've also opened it manually and placed the value from the example XML File from RaptureXML there, so it could not be any mismatches within the XML or else....
But when I use [RXMLElement elementFromXMLFile:filename]
it does not return anything... Any ideas?
Upvotes: 0
Views: 157
Reputation: 692
Better to use initFromXMLFilePath: method.
RXMLElement *rss = [[RXMLElement alloc]initFromXMLFilePath: filePath];
Upvotes: 0
Reputation: 1069
I've now made a workaround: As direct access does not work, I'm first loading the data using standard functions and then transfer the NSData to RaptureXML like this:
NSError *error;
NSString* contents = [NSString stringWithContentsOfFile:filename
encoding:NSUTF8StringEncoding
error:&error];
NSData* xmlData = [contents dataUsingEncoding:NSUTF8StringEncoding];
RXMLElement *rss = [RXMLElement elementFromXMLData:xmlData];
Upvotes: 1