To do this on an iOS device, you would preferably use a third-party C library that implements XPath evaluation for you, as the built-in XML support provided for iOS does not. Your best bet is using libxslt, but because the downloadable version of libxslt come in the form of a dynamic library it can't be used directly on iOS. Instead, you'll want to pull down the source code for libxslt and build it directly into your app. See this SO post for more information on getting libxslt to work on iOS.
Once you have libxslt working in your project, you can use C code to parse the XML and evaluate arbitrary XPath expressions such as "///text()", as was suggested by @Dmitre Novatchev. There are many variants on how you can do this, but something like this gives you an example:
CFArrayRef findImages(CFStringRef filename) {
xmlInitParser();
LIBXML_TEST_VERSION
// Parse XML template document into DOM tree
CFIndex filenameLength = CFStringGetLength(filePath);
char *fileNameCString = (char *) calloc(filenameLength + 1, sizeof(char));
CFStringGetCString(filePath, fileNameCString, filenameLength + 1, kCFStringEncodingUTF8);
xmlDocPtr doc = xmlReadFile(fileNameCString, NULL, 0);
if (doc == NULL)
{
// Error - File not readable
free(fileNameCString);
return nil;
}
else
{
free(fileNameCString);
xmlCleanupParser();
}
/* Create xpath evaluation context */
xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
if(xpathCtx == NULL)
{
// Error - Failed to create Xpath context
return NULL;
}
/* Evaluate xpath expression */
char *xpathCString = "/*/*/text()";
xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST xpathCString, xpathCtx);
if(xpathObj == NULL)
{
// Error - Failed to evaluate XPath
xmlXPathFreeContext(xpathCtx);
return NULL;
}
xmlNodeSetPtr resultNodes = xpathObj->nodesetval;
// You'll want to double-check the following part: I don't have sample code for
// this so I can't be certain this is 100% correct, but it gets the idea across!
CFMutableArrayRef result = CFArrayCreate(kCFAllocatorDefault, 0, NULL);
for (int i = 0; i < resultNodes->nodeNr; i++) {
char *imageCString = xmlNodeGetContent(resultNodes->nodeTab[i]);
CFStringRef imageString = CFStringCreateWithCString(kCFAllocatorDefault, imageCString, kCFStringEncodingUTF8);
CFArrayAppendValue(result, imageString);
}
return result;
}
I've put this code sample together based on some working sample code I had for evaluating an XPath expression, but the end part where I assemble it into an array is off the top of my head: It might not work completely right!
Note that this function takes a CFString for the filename of the XML file and returns a CFArray for the result. These types are "toll-free bridged" with the Objective-C NSString and NSArray types. That means you can call them from objective-C with the "normal" types you are used to using, and they will be correctly understood in the C code I've provided.