@@ -0,0 +1,2619 @@
+package aplicacion;%0A%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Aimport java.lang.ClassLoader;%0A%0Aimport java.util.List;%0Aimport java.util.ArrayList;%0A%0Aimport javax.xml.parsers.DocumentBuilder;%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0Aimport javax.xml.parsers.ParserConfigurationException;%0A%0Aimport org.w3c.dom.Document;%0Aimport org.w3c.dom.Element;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0Aimport org.xml.sax.SAXException;%0A%0Apublic class Parseador %7B%0A%0A%09public void Parsear(String xml) %7B%0A%09%09    //Get the DOM Builder Factory%0A%09%09    DocumentBuilderFactory factory = %0A%09%09    DocumentBuilderFactory.newInstance();%0A%0A%09%09    //Get the DOM Builder%0A%09%09    DocumentBuilder builder;%0A%09%09    Document document = null;%0A%09%09%09try %7B%0A%09%09%09%09builder = factory.newDocumentBuilder();%0A%09%09%09%09//Load and Parse the XML document%0A%09%09%09    //document contains the complete XML as a Tree.%0A%09%09%09%09InputStream in = ClassLoader.getSystemResourceAsStream(xml);%0A%09%09%09%09%0A%09%09%09    document = builder.parse(ClassLoader.getSystemResourceAsStream(xml));%0A%09%09%09    in.available();%0A%09%09%09%7D catch (ParserConfigurationException %7C SAXException %7C IOException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%0A%09%09    List%3CEvento%3E eveList = new ArrayList%3C%3E();%0A%0A%09%09    //Iterating through the nodes and extracting the data.%0A%09%09    NodeList nodeList = document.getDocumentElement().getChildNodes();%0A%0A%09%09    for (int i = 0; i %3C nodeList.getLength(); i++) %7B%0A%0A%09%09      //We have encountered an %3CEvento%3E tag.%0A%09%09      Node node = nodeList.item(i);%0A%09%09      if (node instanceof Element) %7B%0A%09%09        Evento eve = new Evento();%0A%09%09        eve.IdEvento = node.getAttributes().%0A%09%09            getNamedItem(%22id%22).getNodeValue();%0A%0A%09%09        NodeList childNodes = node.getChildNodes();%0A%09%09        for (int j = 0; j %3C childNodes.getLength(); j++) %7B%0A%09%09          Node cNode = childNodes.item(j);%0A%0A%09%09          //Identifying the child tag of Evento encountered. %0A%09%09          if (cNode instanceof Element) %7B%0A%09%09            String content = cNode.getLastChild().%0A%09%09                getTextContent().trim();%0A%09%09            switch (cNode.getNodeName()) %7B%0A%09%09              case %22firstName%22:%0A%09%09                eve.Titulo = content;%0A%09%09                break;%0A%09%09              /*case %22lastName%22:%0A%09%09                eve.lastName = content;%0A%09%09                break;%0A%09%09              case %22location%22:%0A%09%09                eve.location = content;%0A%09%09                break;*/%0A%09%09            %7D%0A%09%09          %7D%0A%09%09        %7D%0A%09%09        eveList.add(eve);%0A%09%09      %7D%0A%0A%09%09    %7D%0A%0A%09%09    //Printing the Evento list populated.%0A%09%09    for (Evento eve : eveList) %7B%0A%09%09      System.out.println(eve);%0A%09%09    %7D%0A%0A%09%7D%0A%09%09%0A%0A%7D%0A

Create Parseador.java