문제

I have a strange xml parsing issue when changing my app's main package name. After changing it everything goes wrong, I have figured out that the text parsed from web is like junk data. I have checked RSS feed from which I parse data but it works fine.And my shared prefernce not working, also have problems with mysql database. I have attached screen shot(Its a grid view to show news titles).Please have a look. I am also attaching the code to parse the xml. Any help would be appreciated..Thanks in advance...

enter image description here

public static void parse() { //method to parse XML feeds

    URL url;

    try {

        url = new URL(urls);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) {

            DocumentBuilderFactory dbf = DocumentBuilderFactory
                    .newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc;
            doc = db.parse(url.openStream());
            doc.getDocumentElement().normalize();

            NodeList itemLst = doc.getElementsByTagName("item");

            nl = doc.getElementsByTagName(KEY_HEAD);

            Description = new String[itemLst.getLength()];// ........
            Title = new String[itemLst.getLength()];
            Tit = new String[itemLst.getLength()];
            Tit2 = new String[itemLst.getLength()];
            Desc = new String[itemLst.getLength()];
            Desc2 = new String[itemLst.getLength()];
            image = new String[itemLst.getLength()];

            for (int i = 0; i < itemLst.getLength(); i++) {

                Node item = itemLst.item(i);
                if (item.getNodeType() == Node.ELEMENT_NODE) {
                    Element ielem = (Element) item;
                    NodeList title = ielem.getElementsByTagName("title");
                    NodeList date = ielem.getElementsByTagName("pubDate");
                    NodeList description = ielem
                            .getElementsByTagName("description");
                    Tit[i] = title.item(0).getChildNodes().item(0)
                            .getNodeValue();

                    Desc[i] = description.item(0).getChildNodes().item(0)
                            .getNodeValue();



                    Tit2[i] = Translate.title(Tit[i]);
                    Desc2[i] = Translate.description(Desc[i]);






                    if (Headlines.headflag == "malayalam") {
                        Desc2[i] = Desc2[i].replace("read more", "IqSpX�");
                    }
                    Title[i] = Tit2[i];
                    if (Desc2[i].contains("<img ")) {
                        String img = Desc2[i].substring(Desc2[i]
                                .indexOf("<img "));
                        String cleanUp = img.substring(0,
                                img.indexOf(">") + 1);
                        img = img.substring(img.indexOf("src=") + 5);
                        int indexOf = img.indexOf("'");
                        if (indexOf == -1) {
                            indexOf = img.indexOf("\"");
                        }
                        img = img.substring(0, indexOf);

                        // setImgLink(img);
                        if (Headlines.headflag == "malayalam") {
                            String img2 = img.replace("files",
                                    "files/imagecache/android_320");
                            Description[i] = Desc2[i].replace(img, img2);
                            image[i] = img2;
                        }

                        else {
                            String img2 = img.replace("files",
                                    "files/imagecache/android_1_img");
                            Description[i] = Desc2[i].replace(img, "");
                            image[i] = img2;
                        }
                    } else {
                        Description[i] = Desc2[i];
                    }

                }

            }

        }

    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DOMException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
도움이 되었습니까?

해결책

Try searching for your old package name in all your classes

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top