Android Extract the value of an element from an xml string
<p>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.</p>

<p>The web server responds with an xml response as follows</p>

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

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

<pre><code>    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(NEW_USER_URL);
    StringBuilder sb = new StringBuilder();

    try {
    sb.append("&lt;mobile_user&gt;");
    sb.append("&lt;auth&gt;");
    sb.append(regId);
    sb.append("&lt;/auth&gt;");
    sb.append("&lt;quiz_id&gt;");
    sb.append("1");
    sb.append("&lt;/quiz_id&gt;");
    sb.append("&lt;/mobile_user&gt;");

    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());
...
</code></pre>

<p>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.</p>

<p>Any help appreciated</p>
