chrisridd/ePub-quicklook — comment on commit e9b63e5991060461d0214091a83423049048124b
File: epub/JTPepub.m line 110
By chrisridd:

A cleaner way to use namespaces is to do something like this:

(in the initialiser? Include all the namespaces you know about...)
static const NSString *ocfns = @"urn:oasis:names:tc:opendocument:xmlns:container";
static const NSString *opfns = @"http://www.idpf.org/2007/opf";
static const NSString *opsns = @"http://www.idpf.org/2007/ops";
static const NSString *dcns = @"http://purl.org/dc/elements/1.1/";
NSDictionary *xmlns = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:ocfns,opfns,opsns,dcns,nil]
forKeys:[NSArray arrayWithObjects:@"ocf",@"opf",@"ops",@"dc",nil]];

Then use nodesForXPath:namespaces:error: like so:

NSArray *nodes = [container nodesForXPath:@"//ocf:rootfile[@media-type='application/oebps-package+xml']/@full-path"
namespaces:xmlns
error:&error];