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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:35:31+00:00 2026-06-07T06:35:31+00:00

I am new to Android Development,and want to parse the XML and bind to

  • 0

I am new to Android Development,and want to parse the XML and bind to Google MapView.
However, i cannot read the Text between element.

The XML

    <?xml version="1.0" encoding="utf8"?>
    <table name="clinicaddress">
        <row>
            <GeoPoint>22.3852860,113.9664120</GeoPoint>
        </row>
        <row>
            <GeoPoint>22.336950,114.1578720</GeoPoint>
        </row>
    </table>

The Code:

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

try {
            inputStream = assetManager.open("clinics.xml");
            String xmlRecords = readTextFile(inputStream);
            //Log.e("Clinics XML", xmlRecords);

            InputSource is = new InputSource();
            is.setCharacterStream(new StringReader(xmlRecords));

            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(is);

            doc.getDocumentElement ().normalize ();

            NodeList listOfClinics = doc.getElementsByTagName("row");
            Log.e("listOfClinics Length" , String.valueOf(listOfClinics.getLength()));

            //Loop the XML

            for (int x = 0; x < listOfClinics.getLength(); x++) {
                Node ClinicNode = listOfClinics.item(x);
                NodeList ClinicInfo = ClinicNode.getChildNodes();
                for (int y = 0; y < ClinicInfo.getLength(); y++) {
                    Node info = ClinicInfo.item(y);
                    Log.e(info.getNodeName() , info.getNodeValue()); //<--Error on info.getNodeValue()
                }
}
            //End Loop XML
        } catch (Exception e) {
            Log.e("tag", e.getMessage());
        }

So, what wrong with getNodeValue()???

enter image description here

And one more question, how can i set the Eclipse like Visual Studio,
If any error, it will break to the line on source line file, instead of just print out the stack message on debug windows.

UPDATED 1.
I found this post:
org.w3c.dom.Node with Android version less than 2.2
org.w3c.dom.Node with Android version less than 2.2

node.getTextContext() is the same as
node.getFirstChild().getNodeValue().

However, i try this, it is goes error too.

  • 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-07T06:35:34+00:00Added an answer on June 7, 2026 at 6:35 am

    Finally, i get this works.

    I use info.getFirstChild().getNodeValue()

            for (int y = 0; y < ClinicInfo.getLength(); y++) {
                Node info = ClinicInfo.item(y);
                if (info.hasChildNodes()) {
                    Log.e(info.getNodeName(), info.getFirstChild().getNodeValue());
                }
            }
    

    Line 3 is important, i Log the hasChildNodes() and watch in LogCat, don’t know why it contains a node named “#text” and no childnodes (which is false on logcat).

    But i believe my XML is correct format.
    After Google, found many explanation.
    https://www.google.com/search?q=xml+%23text

    enter image description here

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

Sidebar

Related Questions

I am very new to Android development and Java. Have read around but I'm
I everyone. I'm very new to Android development and I want to develop an
I am new to android development. I want to make one background application, so
I'm new to Android development, so I might be missing something obvious. I want
I am new to Android development and I want to run PING command through
I'm new in Android development but I like it so far. I want to
I am very new to android development.... i have created an app and want
I am new to Android application development.I want to develop a simple android application
I'm new to android development In my application I want to keep log-in status
I'm new to Android development as well as test-driven development. I want to write

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.