Q:

parse xml with many childs (XmlRpc Response)

This is the monster I receive after a GET request
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
    <param>
        <value>
            <array>
                <data>
                    <value>
                        <struct>
                            <member>
                                <name>DateCreated</name>
                                <value><dateTime.iso8601>20160830T12:57:13</dateTime.iso8601></value>
                            </member>
                            <member>
                                <name>Id</name>
                                <value><i4>17</i4></value>
                            </member>
                        </struct>
                    </value>
                    <value>
                        <struct>
                            <member>
                                <name>DateCreated</name>
                                <value><dateTime.iso8601>20160830T15:57:25</dateTime.iso8601></value>
                            </member>
                            <member>
                                <name>Id</name>
                                <value><i4>43</i4></value>
                            </member>
                        </struct>
                    </value>
                </data>
            </array>
        </value>
    </param>
</params>
</methodResponse>

I want to get the DateCreated and Id values. 
The server may send multiple Ids with different created dates. Is it possible to compare the DateCreated values to get the most recent value?
Here is what I've been able to come with after looking at the docs
Dom.Document doc = res.getBodyDocument();

Dom.XmlNode methodResponse = doc.getRootElement();

String dateCreated = methodResponse.getChildElement('params', null)
                    .getChildElement('value', null)
                    .getChildElement('array', null)
                    .getChildElement('data', null)
                    .getChildElement('value', null)
                    .getChildElement('struct', null)
                    .getChildElement('member', null)
                    .getChildElement('value', null).getText();

String theId = methodResponse.getChildElement('params', null)
                    .getChildElement('value', null)
                    .getChildElement('array', null)
                    .getChildElement('data', null)
                    .getChildElement('value', null)
                    .getChildElement('struct', null)
                    .getChildElement('member', null)
                    .getChildElement('value', null).getText();
return theId;

The return value from theId is

Text Node
  Value   [154]|methodResponse|"XMLNode[ELEMENT,methodResponse,null,null,null,[XMLNode[ELEMENT,params,null,null,null,[XMLNode[ELEMENT,param,null,null,null,[XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,array,null,null,null,[XMLNode[ELEMENT,data,null,null,null,[XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,struct,null,null,null,[XMLNode[ELEMENT,member,null,null,null,[XMLNode[ELEMENT,name,null,null,null,[XMLNode[TEXT,null,null,null,null,null,DateCreated,]],null,], XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,dateTime.iso8601,null,null,null,[XMLNode[TEXT,null,null,null,null,null,20160830T12:57:13,]],null,]],null,]],null,], XMLNode[ELEMENT,member,null,null,null,[XMLNode[ELEMENT,name,null,null,null,[XMLNode[TEXT,null,null,null,null,null,Id,]],null,], XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,i4,null,null,null,[XMLNode[TEXT,null,null,null,null,null,17,]],null,]],null,]],null,]],null,]],null,], XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,struct,null,null,null,[XMLNode[ELEMENT,member,null,null,null,[XMLNode[ELEMENT,name,null,null,null,[XMLNode[TEXT,null,null,null,null,null,DateCreated,]],null,], XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,dateTime.iso8601,null,null,null,[XMLNode[TEXT,null,null,null,null,null,20160830T15:57:25,]],null,]],null,]],null,], XMLNode[ELEMENT,member,null,null,null,[XMLNode[ELEMENT,name,null,null,null,[XMLNode[TEXT,null,null,null,null,null,Id,]],null,], XMLNode[ELEMENT,value,null,null,null,[XMLNode[ELEMENT,i4,null,null,null,[XMLNode[TEXT,null,null,null,null,null,43,]],null,]],null,]],null,]],null,]],null,]],null,]],null,]],null,]],null,]],null,]],null,]"|0x7d6901eb

A:

The below function will return the most recent Id from your HttpResponse. 
public Id getLatestId(HttpResponse res){
    Dom.Document doc = res.getBodyDocument();
    Dom.XmlNode methodResponse = doc.getRootElement();

    List<Dom.XmlNode> dataNodes = methodResponse.getChildElement('params', null)
                    .getChildElement('param', null)
                    .getChildElement('value', null)
                    .getChildElement('array', null)
                    .getChildElement('data', null)
                    .getChildElements();

    List<DateTime> datesToSort = new List<DateTime>();
    Map<DateTime, String> dateToIdMap = new Map<DateTime, String>();

    for(Dom.XmlNode dNode : dataNodes){
        List<Dom.XmlNode> memberNodes = dNode.getChildElement('struct', null)
                    .getChildElements();

        DateTime createdDate = null;
        String id = '';

        for(Dom.XmlNode mNode : memberNodes){
            String name = mNode.getChildElement('name', null)
                    .getText();

            if(name == 'DateCreated'){
                String dt  = mNode.getChildElement('value', null)
                    .getChildElement('dateTime.iso8601', null)
                    .getText();
                //need to prepare the DateTime string for JSON parsing
                dt = dt.substring(0, 4) + '-' + dt.substring(4,6) + '-' + dt.substring(6, dt.length());
                createdDate = (DateTime) JSON.deserialize('"'+dt+'"', DateTime.class);
            }else if(name == 'Id'){
                id  = mNode.getChildElement('value', null)
                    .getChildElement('i4', null)
                    .getText();
            }     
        }

        datesToSort.add(createdDate);
        dateToIdMap.put(createdDate, id);  
    }

    datesToSort.sort();
    String latestId = dateToIdMap.get(datesToSort.get(datesToSort.size()-1));
    System.debug(latestId);
    return latestId;
}

