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 7943221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:12:22+00:00 2026-06-04T00:12:22+00:00

I am using the following code for parsing an XML file. But I don’t

  • 0

I am using the following code for parsing an XML file. But I don’t get any response. Can anyone help?

I am also getting a warning when I open a connection:

“Warning!: Invocation of questionable method: java.lang.String.() found”`?

public static void main(String arg[]){
    XML_Parsing_Sample application = new XML_Parsing_Sample();
    //create a new instance of the application
    //and start the application on the event thread
    application.enterEventDispatcher();
}

public XML_Parsing_Sample() {
    _screen.setTitle("XML Parsing");//setting title
    _screen.add(new RichTextField("Requesting....."));
    _screen.add(new SeparatorField());
    pushScreen(_screen); // creating a screen
    //creating a connection thread to run in the background
    _connectionthread = new Connection();
    _connectionthread.start();//starting the thread operation
}

public void updateField(String node, String element){
    //receiving the parsed node and its value from the thread
    //and updating it here
    //so it can be displayed on the screen
    String title="Title";
    _screen.add(new RichTextField(node+" : "+element));

    if(node.equals(title)){
        _screen.add(new SeparatorField());
    }
}

private class Connection extends Thread{
    public Connection(){
        super();
    }

    public void run(){
        // define variables later used for parsing
        Document doc;
        StreamConnection conn;

        try{
            //providing the location of the XML file,
            //your address might be different
            conn=(StreamConnection)Connector.open
              ("http://www.w3schools.com/xml/note.xml",Connector.READ);
            //next few lines creates variables to open a
            //stream, parse it, collect XML data and
            //extract the data which is required.
            //In this case they are elements,
            //node and the values of an element
            DocumentBuilderFactory docBuilderFactory
              = DocumentBuilderFactory. newInstance(); 
            DocumentBuilder docBuilder
              = docBuilderFactory.newDocumentBuilder();
            docBuilder.isValidating();
            doc = docBuilder.parse(conn.openInputStream());
            doc.getDocumentElement ().normalize ();
            NodeList list=doc.getElementsByTagName("*");
            _node=new String();
            _element = new String();
            //this "for" loop is used to parse through the
            //XML document and extract all elements and their
            //value, so they can be displayed on the device

            for (int i=0;i<list.getLength();i++){
                Node value=list.item(i).
                  getChildNodes().item(0);
                _node=list.item(i).getNodeName();
                _element=value.getNodeValue();
                updateField(_node,_element);
            }//end for
        }//end try
        //will catch any exception thrown by the XML parser
        catch (Exception e){
            System.out.println(e.toString());
        }
    }//end connection function
}// end connection class
  • 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-04T00:12:24+00:00Added an answer on June 4, 2026 at 12:12 am

    You are probably timing out.
    Try opening the connection as HTTP connection instead, and use the new ConnectionFactory class to get rid of annoying suffixes.

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

Sidebar

Related Questions

I am using the following code by the Android-people-XMLParsing example for parsing XML file
I am using the following code for parsing of small xml files and it
i'm using the following code: - (void)parserDidStartDocument:(NSXMLParser *)parser{ NSLog(@File found and parsing started); }
Using following code I try to get updated list of checkbuttons' corresponding text values,
I'm using following code but cannot return data from MySQL. This is the output:
I am using following code for add button with image on tool bar, but
I am parsing XML using jQuery. I want to get the count of all
I'm new to xml parsing, I am trying to parse the following xml file
I want to read a XML file, using XMLReader but the END ELEMENT is
In the following code, I am trying to do a text parsing by using

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.