You could go with XPath but IMHO it would be overkill.
To me it sounds like you need a Map of some sort to keep track of the pages. I would personally avoid the use of strings array (since I don't think there is anyway to reference an attribute for an element) as follows:
// create HashMap to write pages to
Map<String, Integer> bookPageMapping = new HashMap<String, Integer>();
bookPageMapping.put("book1", 428);
bookPageMapping.put("book2", 599);
bookPageMapping.put("book3", 204);
You could also, put the book literals into the strings.xml as follows and reference them that way as well:
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MultiArray</string>
<string name="book1">book1</string>
<string name="book2">book2</string>
<string name="book3">book3</string>
</resources>
Then you would reference the files in your code as follows:
// create HashMap to write pages to
Map<String, Integer> bookPageMapping = new HashMap<String, Integer>();
bookPageMapping.put(getString(R.string.book1), 428);
bookPageMapping.put(getString(R.string.book1), 599);
bookPageMapping.put(getString(R.string.book1), 204);
Or you could go with the strings array:
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MultiArray</string>
<string-array name="books">
<item>book1</item>
<item>book2</item>
<item>book3</item>
</string-array>
</resources>
Then populate the hashmap accordingly:
// get the String array from resources
Resources res = getResources();
String[] books = res.getStringArray(R.array.books);
// create HashMap to write pages to
Map<String, Integer> bookPageMapping = new HashMap<String, Integer>();
bookPageMapping.put(books[0], 428);
bookPageMapping.put(books[1], 599);
bookPageMapping.put(books[2], 204);
For more information see the Android Developer's site and do a search for String Resources or Map. I would have directly posted those links but since I am a new user, I cannot post more than 1 hyperlink. BTW, this is my first Stack Overflow post so be gentle :)