@@ -0,0 +1,3365 @@
+package u2Home.task2;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0Aimport javax.xml.parsers.DocumentBuilder;%0Aimport javax.xml.parsers.ParserConfigurationException;%0Aimport javax.xml.xpath.XPath;%0Aimport javax.xml.xpath.XPathConstants;%0Aimport javax.xml.xpath.XPathExpressionException;%0Aimport javax.xml.xpath.XPathFactory;%0A%0Aimport org.w3c.dom.Document;%0Aimport org.w3c.dom.NodeList;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.Element;%0Aimport org.xml.sax.SAXException;%0A%0Apublic class Parser %7B%0A    public static void main(String%5B%5D args) %7B%0A        try %7B%0A            String inputFile = %22C:%5C%5CUsers%5C%5CI%5C%5CDocuments%5C%5Cyql.xml%22;%0A            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();%0A            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();%0A            Document doc = dBuilder.parse(inputFile);%0A            doc.getDocumentElement().normalize();%0A%0A            XPath xPath =  XPathFactory.newInstance().newXPath();%0A%0A            String expression = %22//results/rate%22;%0A            NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);%0A            for (int i = 0; i %3C nodeList.getLength(); i++) %7B%0A                Node nNode = nodeList.item(i);%0A//                System.out.println(%22%5Cn%D0%92%D0%B0%D0%BB%D1%8E%D1%82%D0%B0 :%22%0A//                        + nNode.getNodeName());%0A                if (nNode.getNodeType() == Node.ELEMENT_NODE) %7B%0A                    Element eElement = (Element) nNode;%0A                    System.out.println(%22id : %22%0A                            + eElement.getAttribute(%22id%22));%0A                    System.out.println(%22Name : %22%0A                            + eElement%0A                            .getElementsByTagName(%22Name%22)%0A                            .item(0)%0A                            .getTextContent());%0A                    System.out.println(%22Rate : %22%0A                            + eElement%0A                            .getElementsByTagName(%22Rate%22)%0A                            .item(0)%0A                            .getTextContent());%0A                    System.out.println(%22Date : %22%0A                            + eElement%0A                            .getElementsByTagName(%22Date%22)%0A                            .item(0)%0A                            .getTextContent());%0A                    System.out.println(%22Time : %22%0A                            + eElement%0A                            .getElementsByTagName(%22Time%22)%0A                            .item(0)%0A                            .getTextContent());%0A                    System.out.println(%22Ask : %22%0A                            + eElement%0A                            .getElementsByTagName(%22Ask%22)%0A                            .item(0)%0A                            .getTextContent());%0A                    System.out.println(%22Bid : %22%0A                            + eElement%0A                            .getElementsByTagName(%22Bid%22)%0A                            .item(0)%0A                            .getTextContent()%0A                            + %22%5Cn=========%22);%0A%0A                %7D%0A            %7D%0A        %7D catch (ParserConfigurationException e) %7B%0A            e.printStackTrace();%0A        %7D catch (SAXException e) %7B%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D catch (XPathExpressionException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A

add work parser yahooFinance