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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:13:53+00:00 2026-06-12T08:13:53+00:00

I’ve an Android app that gets an xml response from a webservice call. I

  • 0

I’ve an Android app that gets an xml response from a webservice call. I am trying to parse the xml using DOM parser. I’m having trouble getting the values of the StartDate tags as well as the other tags in the call tag. Any ideas where i’m going wrong. When i log the value out from the startDate, it’s empty. Thanks.

public class DomParser {

    private static final String TAG = DomParser.class.getSimpleName();
    DocumentBuilderFactory builderFactory;
    DocumentBuilder builder;
     Document document;

    public DomParser() {
        super();
        Log.e(TAG, "inside domparser constructor");
        builderFactory = DocumentBuilderFactory.newInstance();
        document = null;
        try {
            builder = builderFactory.newDocumentBuilder();
            Log.e(TAG, "built the dom factory");
        } catch (ParserConfigurationException e) {
            e.printStackTrace();  
        }
    }// end of constructor


    public void parseXmlString(String str){

        try {
            String s = str.replace("&lt;", "<");
            String t = s.replace("&gt;", ">");
            document = builder.parse( new InputSource(new StringReader(t))); 
            Log.e(TAG, "document = " + document);
            Log.e(TAG, "str = " + t);
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.e(TAG, "about to parse the rootElement");
        Element rootElement = document.getDocumentElement();
        NodeList nodes = rootElement.getChildNodes();

        Node rota = nodes.item(0);
        NodeList callList = rota.getChildNodes();

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

            Node call = callList.item(i);
            NodeList callChildrenList = call.getChildNodes();

            for(int j = 0; j < callChildrenList.getLength(); j++){
                Node callChild = callChildrenList.item(j);
                if(callChild instanceof Element){
                    //a child element to process
                    Element child = (Element) callChild;
                    String startDate = child.getAttribute("StartDate"); 
                    Log.e(TAG, "element StartDate = " + startDate);
                  }
            }

        }



    }//end of parseXmlString

}

.

  <?xml version="1.0" encoding="utf-8"?>
    10-05 15:49:17.680: E/DomParser(31495): <string xmlns="http://tempuri.org/"><Rota><Call><StartDate>2012-10-05T07:00:00+01:00</StartDate><EndDate>2012-10-05T07:25:00+01:00</EndDate><Duration>25</Duration><CallStatusID>1</CallStatusID><CallStatusName>Completed</CallStatusName><ClientSurname>Ebbs</ClientSurname><ClientForename>Vera</ClientForename><NeedName>Assist With Dressing, Laundry, Leave A Drink, Leave A Sandwich For Later, Make A Hot Drink, Prepare Breakfast, Shower, TIME BAND - Early Breakfast</NeedName><CarerAwayReason /><CallID>47418572-73a1-4dab-bc24-739c122b2b25</CallID><ActualTimeIn>07:30</ActualTimeIn><ActualTimeOut>07:49</ActualTimeOut></Call><Call><StartDate>2012-10-05T07:30:00+01:00</StartDate><EndDate>2012-10-05T08:00:00+01:00</EndDate><Duration>30</Duration><CallStatusID>1</CallStatusID><CallStatusName>Completed</CallStatusName><ClientSurname>Brown</ClientSurname><ClientForename>Margaret</ClientForename><NeedName>Careline, Diabetic Type 2, Empty Commode, KEY SAFE, Leave A Drink, Make A Hot Drink, Meds - Level II Administer, Prepare Snack, TIME BAND - Early Bed</NeedName><CarerAwayReason /><CallID>14f4f796-c7a6-4942-9d91-e9e7a40394f5</CallID><ActualTimeIn>08:00</ActualTimeIn><ActualTimeOut>08:21</ActualTimeOut></Call><Call><StartDate>2012-10-05T08:00:00+01:00</StartDate><EndDate>2012-10-05T08:40:00+01:00</EndDate><Duration>40</Duration><CallStatusID>1</CallStatusID><CallStatusName>Completed</CallStatusName><ClientSurname>Weaver</ClientSurname><ClientForename>Margaret</ClientForename><NeedName>KEY SAFE, Morning Call - Get Up And Breakfast, Personal Care</NeedName><CarerAwayReason /><CallID>2a7e6c70-ee2c-4657-a313-a18b87a766ed</CallID><ActualTimeIn>08:35</ActualTimeIn><ActualTimeOut>09:13</ActualTimeOut></Call><Call><StartDate>2012-10-05T09:00:00+01:00</StartDate><EndDate>2012-10-05T09:20:00+01:00</EndDate><Duration>20</Duration><CallStatusID>3</CallStatusID><CallStatusName>NCR</CallStatusName><ClientSurname>Howarth</ClientSurname><ClientForename>Edith</ClientForename><NeedName>Change Incontinence Pads, KEY SAFE, Make Bed / Change As Neccessary, Meds - Level II Administer, Personal Care, Prepare Breakfast, TIME BAND - Late Breakfast</NeedName><CarerAwayReason /><CallID>383c9be6-4cbe-459a-92ed-5dc309a0bffb</CallID></Call><Call><StartDate>2012-10-05T09:00:00+01:00</StartDate><EndDate>2012-10-05T09:30:00+01:00</EndDate><Duration>30</Duration><CallStatusID>1</CallStatusID><CallStatusName>Completed</CallStatusName><ClientSurname>Kastik</ClientSurname><ClientForename>Lydia</ClientForename><NeedName>Keys Needed, Leave A Drink, Leave A Sandwich For Later, Make A Hot Drink, Make Bed / Change As Neccessary, Medication Prompt, Meds - Level II Administer, Personal Care, TIME BAND - Early Breakfast</NeedName><CarerAwayReason /><CallID>f4cc1f96-ef65-4231-9e03-0b8263b04d27</CallID><ActualTimeIn>09:28</ActualTimeIn><ActualTimeOut>09:57</ActualTimeOut></Call><Call><StartDate>2012-10-05T10:30:00+01:00</StartDate><EndDate>2012-10-05T11:00:00+01:00</EndDate><Duration>30</Duration><CallStatusID>1</CallStatusID><CallStatusName>Completed</CallStatusName><ClientSurname>Terett</ClientSurname><ClientForename>Mamie</ClientForename><NeedName>Assist With Dressing, Meds - Self Medicating, Morning Call, Personal Care, Strip Wash, TIME BAND - Late Breakfast</NeedName><CarerAwayReason /><CallID>03f52182-b9ff-4fa9-9b71-1a20b8bbeeaa</CallID><ActualTimeIn>10:10</ActualTimeIn><ActualTimeOut>10:57</ActualTimeOut></Call><Call><StartDate>2012-10-05T12:00:00+01:00</StartDate><EndDate>2012-10-05T12:15:00+01:00</EndDate><Duration>15</Duration><CallStatusID>1</CallStatusID><CallStatusName>Completed</CallStatusName><ClientSurname>Garland</ClientSurname><ClientForename>Mavis</ClientForename><NeedName>Empty Catheter Bag, Medication Prompt, Meds - Level II Administer, TIME BAND - Early Lunch, Toiletting / Commode</NeedName><CarerAwayReason /><CallID>802d8adf-3a80-40bd-be91-f29db7c1291e</CallID><ActualTimeIn>11:16</ActualTimeIn><ActualTimeOut>11:38</ActualTimeOut></Call><Call><StartDate>2012-10-05T12:30:00+01:00</StartD

[update]

Element rootElement = document.getDocumentElement();
        NodeList nodes = rootElement.getChildNodes();

        Node rota = nodes.item(0);
        NodeList callList = rota.getChildNodes();

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

            Node call = callList.item(i);
            NodeList callChildrenList = call.getChildNodes();


            for(int j = 0; j < callChildrenList.getLength(); j++){
                Node callChild = callChildrenList.item(j);

                Log.e(TAG, "callChild name = " + callChild.getNodeName());


            }
  • 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-12T08:13:54+00:00Added an answer on June 12, 2026 at 8:13 am

    Something like this based on your new example code

    // HERE LOOP TO FIND THE NODE LIKE YOU HAVE DONE IN YOUR EXAMPLE
    // WHERE YOU HAVE callChild.getNodeName() AND LOOK FOR THE ONE THAT IS "StartDate"
    // ASSUMING startDateNode HERE IS THE NODE YOU WANT
    
        // GET THE CHILD NODES AND LOOK FOR THE TEXT NODE  
        NodeList nList = startDateNode.getChildNodes();
        for (int i=0; i < nList.getLength(); i++) {
           Node tmpNode = nList.item(i);
           if (tmpNode.getNodeType() == Node.TEXT_NODE) {
              String dateStr = ((CharacterData)tmpNode).getData();
               // NOW YOU HAVE THE CHARACTER DATA
              // DO SOMETHING WITH THE VALUE
           }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload

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.