The stringValue of some elements from an XML files contain BOM characters in them. The xml file is marked as UTF-8 encoding.
Some of those characters are at the beginning of the string (as it should be from what I read about it) but some are in the middle of the string (malformed string from whoever wrote the xml file maybe?).
I'm opening the file with:
NSURL *furl = [NSURL fileURLWithPath:fileName];
if (!furl) {
NSLog(@"Error: Can't open NML file '%@'.", fileName);
return kNxADbReaderTTError;
}
NSError *err=nil;
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:furl options:NSXMLNodeOptionsNone error:&err];
And I query the element this way:
NSXMLElement *anElement;
NSString *name;
...
NSString *valueString = [[anElement attributeForName:name] stringValue];
My questions are:
Am I opening the file wrong? Is the file malformed? Am I querying the string value of the element wrong? How can I filter those characters out?