class OpenStackParser {

    public Quota parseComputeQuotaResponse(String response) throws OCCIException {
    	Element vcpu, ram, servers;
        Quota ret = new Quota();
        SAXBuilder builder = new SAXBuilder();
        builder.setValidation(false);
        builder.setIgnoringElementContentWhitespace(true);
        Document xmldoc;
        
        log.info("[OpenStackParser] Parsing compute quota response...");
        try {
            xmldoc = builder.build(new StringReader(response));
            XPath xpath = XPath.newInstance("//cores");
            vcpu = (Element) xpath.selectSingleNode(xmldoc);
            
            xpath = XPath.newInstance("//ram");
            ram = (Element) xpath.selectSingleNode(xmldoc);
            
            xpath = XPath.newInstance("//instances");
            servers = (Element) xpath.selectSingleNode(xmldoc);
            
            if (vcpu != null && ram != null && servers!= null) {
            	ret.setCpu(Integer.parseInt(vcpu.getValue()));
            	ret.setMemory(Integer.parseInt(ram.getValue()));
            	ret.setNumVms(Integer.parseInt(servers.getValue()));
            } else {
            	OCCIException exception = new OCCIException();
                exception.setMessage(MALFORMEDRESPONSE);
                log.error(MALFORMEDRESPONSE);
                throw exception;
            }
        } catch (JDOMException e) {
            log.error(e.getMessage());
        } catch (IOException e) {
            log.error(e.getMessage());
        }
        log.debug("[OpenStackParser] Compute quota response parsed...");
        
        return ret;
    }

}