I am using XPath to query an oracle database where the field I am querying looks like:
<!-- language: lang-xml -->
<film>
<title>Godfather, The</title>
<year>1972</year>
<directors>
<director>Francis Ford Coppola</director>
</directors>
<genres>
<genre>Crime</genre>
<genre>Drama</genre>
</genres>
<plot>Son of a mafia boss takes over when his father is critically wounded in a mob hit.</plot>
<cast>
<performer>
<actor>Marlon Brando</actor>
<role>Don Vito Corleone</role>
</performer>
<performer>
<actor>Al Pacino</actor>
<role>Michael Corleone</role>
</performer>
<performer>
<actor>Diane Keaton</actor>
<role>Kay Adams Corleone</role>
</performer>
<performer>
<actor>Robert Duvall</actor>
<role>Tom Hagen</role>
</performer>
<performer>
<actor>James Caan</actor>
<role>Sonny Corleone</role>
</performer>
</cast>
</film>
I want to return the all the actors who have starred in the film the godfather. At the minute my code looks like:
result = stmt.executeQuery("SELECT a.FILM.extract('/film[title=\"Godfather, The\"]/cast/performer/actor/text()') "
+ "FROM ASS2_Film a "
+ "WHERE a.film.existsNode('/film[title=\"Godfather, The\"]')=1");
System.out.println("\nActor");
while (result.next()) {
System.out.println(result.getString(1)+"\n");
}
At the minute my code is returning:
Actor
Marlon BrandoAl PacinoDiane KeatonRobert DuvallJames Caan
Where as I want it returned as:
Actor
Marlon Brando
Al Pacino
Diane Keaton
Robert Duvall
James Caan
Thanks for any help
No comments:
Post a Comment