Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8029607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:29:15+00:00 2026-06-05T00:29:15+00:00

I am a newbie of Blackberry developing application. I try to store all xml

  • 0

I am a newbie of Blackberry developing application. I try to store all xml parsing data to an object, and set them to a vector.

public class XmlParser extends MainScreen {
    Database d;
    private HttpConnection hcon = null;

    private Vector binN;
    public Vector getBinN() {
        return binN;
    }

    public void setBinN(Vector bin) {
        this.binN = bin;
    }

    LabelField from;
    LabelField ttl;
    LabelField desc;
    LabelField date;

    public XmlParser() {
        LabelField title = new LabelField("Headline News" ,LabelField.HCENTER|LabelField.USE_ALL_WIDTH);
        setTitle(title);

        try {
            URI myURI = URI.create("file:///SDCard/Database/WebFeed.db"); 
            d = DatabaseFactory.open(myURI);
            Statement st = d.createStatement("SELECT feed_url, feed_name FROM WebFeed");
            st.prepare();
            Cursor c = st.getCursor();
            while (c.next()) {
                Row r = c.getRow();
                hcon = (HttpConnection)Connector.open(r.getString(0));
                hcon.setRequestMethod(HttpConnection.GET);
                        hcon.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
                        hcon.setRequestProperty("Content-Length", "0");
                        hcon.setRequestProperty("Connection", "close");
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();

                builder.isValidating();
                Document document = builder.parse(hcon.openInputStream());

                Element rootElement = document.getDocumentElement();
                rootElement.normalize();

                NodeList list = document.getElementsByTagName("item");

                int i=0;
                while (i<10){
                    Node item = list.item(i);
                    if(item.getNodeType() != Node.TEXT_NODE) {
                        NodeList itemChilds = item.getChildNodes();
                        int j=0;
                        while (j<10){
                            Node detailNode = itemChilds.item(j);
                            if(detailNode.getNodeType() != Node.TEXT_NODE) {                                
                                if(detailNode.getNodeName().equalsIgnoreCase("title")) {
                                    ttl = new LabelField(getNodeValue(detailNode)) {
                                        public void paint(Graphics g) {
                                            g.setColor(Color.BLUE);
                                            super.paint(g);
                                        }
                                    };
                                    from = new LabelField(r.getString(1), LabelField.FIELD_RIGHT|LabelField.USE_ALL_WIDTH);
                                    ttl.setFont(Font.getDefault().derive(Font.BOLD));
                                    from.setFont(Font.getDefault().derive(Font.BOLD));
                                    add (from);
                                    add (ttl);
                                } else if(detailNode.getNodeName().equalsIgnoreCase("description")) {

                                    desc = new LabelField(getNodeValue(detailNode), 0, 70, USE_ALL_WIDTH);
                                    add(desc);
                                } else if(detailNode.getNodeName().equalsIgnoreCase("dc:date")) {
                                    date = new LabelField(getNodeValue(detailNode), 11, 5, USE_ALL_WIDTH) {
                                        public void paint(Graphics g) {
                                            g.setColor(Color.ORANGE);
                                            super.paint(g);
                                        }
                                    };
                                    add(date);
                                    add(new SeparatorField());
                                } else if(detailNode.getNodeName().equalsIgnoreCase("pubDate")) {
                                    date = new LabelField(getNodeValue(detailNode), 0, 22, USE_ALL_WIDTH) {
                                        public void paint(Graphics g) {
                                            g.setColor(Color.ORANGE);
                                            super.paint(g);
                                        }
                                    };
                                    add(date);
                                    add(new SeparatorField());
                                } else {
                                    System.out.println("not the node");
                                }
                            } else {
                                System.out.println("not text node");
                            }
                            j++;
                        }
                    }
                    i++;
                    BinNews bin = new BinNews();
                    bin.setProv(from.getText());
                    bin.setTitle(ttl.getText());
                    bin.setDesc(desc.getText());
                    bin.setDate(date.getText());
                    binN.addElement(bin);
                }
                setBinN(binN);
            }
            //setBinN(binN);
            st.close();
            d.close();
        } catch (Exception e)  {
            add (new LabelField(e.toString(),LabelField.HCENTER|LabelField.USE_ALL_WIDTH));
            System.out.println(e.toString());
        }
    }

    public String getNodeValue(Node node) {
        NodeList nodeList = node.getChildNodes();
        Node childNode = nodeList.item(0);
        return childNode.getNodeValue();
    }
}

I try to store all data from an object called BinNews, to a vector called binN. But when I do debugging, I found that BinN has null value, because “binN.addElement(bin)” doesn’t work.
Please advise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:29:17+00:00Added an answer on June 5, 2026 at 12:29 am

    First, you don’t actually call setBinN until after the while(i < 10) loop completes. So when you say binN.addElement(bin) then binN will be null.

    However your setBinN(binN) call doesn’t make sense because you’re passing in binN and then setting it to itself which isn’t going to do anything.

    What you can do is have binN = new Vector(); at the top of the constructor and then it won’t be null later on. I don’t think the setBinN call will be necessary later on if you’re adding the BinNews objects straight to binN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question... I am using silverlight to POST data to my GAE application class
Newbie question. I'm developing a web application (I'm using Flex/AS3, but for the purposes
I am a Blackberry newbie. I develop on Mac OS Lion. I just installed
I am a blackberry development newbie. I want to find out a unique identifier
Newbie question since I'm not up to speed using maven at all. I'm trying
(Newbie DBUnit question Alert!) It appears that DBUnit for each table 'deletes all the
I am a newbie at Blackberry development. I am making an app which I
Newbie Java question - On all the posts for Auto Scaling the Text view,
Newbie Alert: while working on my android application my program was acting kind of
Newbie C++ programmer here. I'm trying to write a command line application that takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.