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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:29:59+00:00 2026-05-26T04:29:59+00:00

How do I get the values of id, created_at and updated at from an

  • 0

How do I get the values of id, created_at and updated at from an XML response after creating a new record on a web server.

The web server responds with an xml response as follows

<mobile-user>
    <active type="boolean">true</active>
    <created-at type="datetime">2011-10-14T14:20:51Z</created-at>
    <id type="integer">4</id>
    <quiz-id type="integer">0</quiz-id>
    <updated-at type="datetime">2011-10-14T14:20:51Z</updated-at>
</mobile-user>

The code I use to create the record on the android app (inside an intent service) looks like this

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(NEW_USER_URL);
    StringBuilder sb = new StringBuilder();

    try {
    sb.append("<mobile_user>");
    sb.append("<auth>");
    sb.append(regId);
    sb.append("</auth>");
    sb.append("<quiz_id>");
    sb.append("1");
    sb.append("</quiz_id>");
    sb.append("</mobile_user>");

    StringEntity entity = new StringEntity(sb.toString(), "UTF-8");
    httppost.setEntity(entity);  
    httppost.addHeader("Accept", "application/xml");
    httppost.addHeader("Content-Type", "application/xml");

    HttpResponse response = httpclient.execute(httppost);       
    String responseXml = EntityUtils.toString(response.getEntity());
...

So I assume (correctly?) that responseXml string contains the xml response above
All I need to do now is as efficiently as possible extract the id, created_at and updated_at values from that string into a new string for each value.

Any help appreciated

  • 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-05-26T04:30:00+00:00Added an answer on May 26, 2026 at 4:30 am

    Using DOM it seems to be like:

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            Document dom;
            try {
                DocumentBuilder builder = factory.newDocumentBuilder();
                StringReader reader = new StringReader(responseXml);
                InputSource source = new InputSource(reader);
                dom = builder.parse(source);
            } catch (ParserConfigurationException e) {
            } catch (SAXException e) {
            } catch (IOException e) {
            }
            if (dom != null) {
                Element root = dom.getDocumentElement();
                NodeList idItem = root.getElementsByTagName("id");
                NodeList createdAtItem = root.getElementsByTagName("created-at");
                NodeList updatedAtItem = root.getElementsByTagName("updated-at");
    
                String id = idItem.item(0).getChildNodes().item(0).getNodeValue();
                String createdAt = createdAtItem.item(0).getChildNodes().item(0).getNodeValue();
                String updatedAt = updatedAtItem.item(0).getChildNodes().item(0).getNodeValue();
            }
    

    Ugly variant, but it must be work.

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

Sidebar

Related Questions

I want to get the CreateDate value from xml file the xml file is
I created the following code,which enables the dropdown to get all the values from
I'm trying to get values from nsdata class and doesn't work. here is my
I want to get values from a row with the largest certain value (in
I use jQuery to get values of presaved elements from some websites, using paths
I am trying to get values from a data set. My function has to
How to get the maximum axis value from a created chart? Here is how
I need to get values of these check boxes with same name through HTTP
Trying to get a value from a object isn't working out. class Asset <
We are building a system that gets XML data from a database, uses XSLT

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.