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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:39:34+00:00 2026-06-15T12:39:34+00:00

I am trying to read an xml file from android application but xml file

  • 0

I am trying to read an xml file from android application but xml file is being generated from php instantly (so the file is .php)

When i am asking on that url from java i get this error : Expected file scheme in URI : “http://someserver.com/foo/bar/Myuri.php”

try {
          File file = new File(new URI("http://someserver.com/foo/bar/Myuri.php"));
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder db = dbf.newDocumentBuilder();
          Document doc = db.parse(file);
          doc.getDocumentElement().normalize();
          System.out.println("Root element " + doc.getDocumentElement().getNodeName());
          NodeList nodeLst = doc.getElementsByTagName("employee");
          //System.out.println("Information of all employees");

          for (int s = 0; s < nodeLst.getLength(); s++) {

            Node fstNode = nodeLst.item(s);

            if (fstNode.getNodeType() == Node.ELEMENT_NODE) {

                   Element fstElmnt = (Element) fstNode;
              NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("name");
              Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
              NodeList fstNm = fstNmElmnt.getChildNodes();
              System.out.println("Name : "  + ((Node) fstNm.item(0)).getNodeValue());
              NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("lastname");
              Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
              NodeList lstNm = lstNmElmnt.getChildNodes();
              System.out.println("Last Name : " + ((Node) lstNm.item(0)).getNodeValue());
            }

          }
          } catch (Exception e) {
            alertDialog.setMessage(e.getMessage());
            alertDialog.show();
          }
  • 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-15T12:39:35+00:00Added an answer on June 15, 2026 at 12:39 pm

    EDIT: Okay, now we’ve got some code, let’s look at the important line:

    File file = new File(new URI("http://someserver.com/foo/bar/Myuri.php"));
    

    The File class is for files. Not arbitrary URIs. It’s expecting a file scheme in the URI, e.g. file://.

    Basically, you can’t use File to get stuff off the web. That’s not what it’s there for. Use an HTTP library, e.g. HttpClient.

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

Sidebar

Related Questions

I have one .net windows application I'm trying to read .xml file from c#
I have an XML file that I'm trying to read from here , and
I have a really simple XML file that I'm trying to read, but I
I'm trying to read from an XML file and use that to populate a
I want to parse an XML file from URL using JDOM. But when trying
I've been trying to read a node in an xml file generated from DSLR
I have an xml file(from federal government's data.gov) which I'm trying to read with
I'm trying to read data from an xml file and display it in a
I'm trying to read the data from an XML file, validating it against the
I'm trying to read in some sample data from an XML file in a

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.