Xpath: Selecting all of an element type?
- by Johannes
I'm just starting to learn Xpath, I'm trying to write a line of code that will select all of the actors in EACH movie parent (through Java!). Below, I have an example of one movie, but there are multiple <Movie> elements, each with <Actor> elements.
<Movie Genre = 'Other'>
<Title>Requiem For A Dream</Title>
<ReleaseYear>2000</ReleaseYear>
<Director>Darren Aronofsky</Director>
<Actor Character = 'Sara Goldfarb'>Ellen Burstyn</Actor>
<Actor Character = 'Harry Goldfarb'>Jared Leto</Actor>
<Actor Character = 'Marion Silver'>Jennifer Connelly</Actor>
<Actor Character = 'Tyrone C. Love'>Marlon Wayans</Actor>
</Movie>
Currently, I can only select the first <Actor> element of each <Movie> element -- is it possible to select all of them without using a for loop?
Here is my current line of code that displays the first <Actor> element of every <Movie> element:
System.out.println("Starring: " + xpath.evaluate("Actor", movieNode) + " as " + xpath.evaluate("Actor/@Character", movieNode) + "\n");
Any and all help if much appreciated!