Code example for DocumentBuilderFactory

Methods: newDocumentBuildersetValidating

0
    void init() throws IOException, ParserConfigurationException, SAXException { 
        urlConnection = url.openConnection();
        urlConnection.setConnectTimeout(20000);
        urlConnection.connect();
        documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setValidating(false);
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        document = documentBuilder.parse(urlConnection.getInputStream());
        node = document.getChildNodes().item(0).getFirstChild();
        nodeList = document.getChildNodes().item(0).getChildNodes();
    } 
 
    String[] getForecastById(int x) {
        switch (x) {
            case 1: 
                return new String[]{"PICT1", "T1"};
            case 2: 
                return new String[]{"PICT2", "T2"};
            case 3: 
                return new String[]{"PICT3", "T3"};
Contextual code suggestions in your IDE  Get Codota for Java