Usa Xpath para responder a las siguientes preguntas sobre el archivo hamlet.xml.
Nota: Consultas realizadas dentro de los sitios web XPather y FreeFormatter
R:
//ACT[2]/SCENE/TITLE
Devuelve:
1. A room in POLONIUS' house.
2. A room in the castle.
R:
count(//SPEECH[SPEAKER='HAMLET'])
Devuelve : 359
R:
//LINE[contains(text(), 'king')]
Devuelve :
1. Long live the king!
2. In the same figure, like the king that's dead.
3. Looks it not like the king? mark it, Horatio.
....... y otros mas
R:
//ACT[3]//SPEECH[SPEAKER='BERNARDO'][2]
No devuelve nada porque no hay dialogo de este personaje en este acto. Pero se puede comprobar usando KING CLAUDIUS en su lugar por ejemplo y verificar hamlet.xml
R:
//SPEECH/ count(LINE)
o
for $s in //SPEECH return count($s/LINE)
R:
max(//SPEECH/ count(LINE))
Nos devuelve 60
Si queremos obtener la 3ra PERSONA del 1er PGROUP dentro de PERSONAE
//PERSONAE//PGROUP[1]//PERSONA[3] <!-- nos da ROSENCRANTZ -->
R:
//SPEECH[SPEAKER = //PERSONAE//PGROUP[1]//PERSONA[3] ] <!-- nos da los SPEECH de ese SPEAKER -->
Nos devuelve:
Element='<SPEECH>
<SPEAKER>ROSENCRANTZ</SPEAKER>
<LINE>Both your majesties</LINE>
<LINE>Might, by the sovereign power you have of us,</LINE>
<LINE>Put your dread pleasures more into command</LINE>
<LINE>Than to entreaty.</LINE>
</SPEECH>'
Element='<SPEECH>
<SPEAKER>ROSENCRANTZ</SPEAKER>
<LINE>
<STAGEDIR>To POLONIUS</STAGEDIR> God save you, sir!</LINE>
</SPEECH>'
.... y otros mas