1 import org.xml.sax.Attributes;
2 import org.xml.sax.SAXException;
3 import org.xml.sax.helpers.DefaultHandler;
5 public class ejercicioSax3 extends DefaultHandler{
14 public ejercicioSax3() {
20 this.artistaValor = "";
21 this.tituloValor = "";
25 public void startElement(String uri, String localName, String name,
26 Attributes attributes) throws SAXException {
28 if (localName.equals("cd")){
30 }else if(localName.equals("titulo")){
32 }else if(localName.equals("artista")){
34 }else if(localName.equals("pais")){
39 public void characters(char[] ch, int start, int length)
41 String texto = String.valueOf(ch, start, length);
43 if (!texto.equals("") && cd){
45 this.tituloValor = texto;
47 this.artistaValor = texto;
49 this.paisValor = texto;
53 public void endElement(String uri, String localName, String name)
55 if (localName.equals("cd")){
57 if (paisValor.equals("USA"))
58 System.out.println("titulo: "+ tituloValor + " | artista: " + artistaValor);
59 }else if(localName.equals("titulo")){
62 else if(localName.equals("artista")){
65 else if(localName.equals("pais")){