class OpenStackParser {

    public List<Nic> parseVirtualInterfacesResponse (String response) 
                                                        throws OCCIException {
    	List<Nic> ret = null;
    	Nic nic;
        Link link;
        SAXBuilder builder = new SAXBuilder();
        builder.setValidation(false);
        builder.setIgnoringElementContentWhitespace(true);
        Document xmldoc;
        
        log.info("[OpenStackParser] Parsing virtual interfaces response...");
        try {
            xmldoc = builder.build(new StringReader(response));
            XPath xpath = XPath.newInstance("//ns:virtual_interfaces/@mac_address");
            xpath.addNamespace("ns", COMPUTENAMESPACE);
            xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE);
            List macList = xpath.selectNodes(xmldoc);
            
            xpath = XPath.newInstance("//ns:virtual_interfaces/@OS-EXT-VIF-NET:net_id");
            xpath.addNamespace("ns", COMPUTENAMESPACE);
            xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE);
            List networkList = xpath.selectNodes(xmldoc);
            
            if (macList.size() > 0 && networkList.size() > 0) {
                ret = new ArrayList<Nic>();
                
                for (int i = 0 ; i < macList.size() ; i++) {
                	nic = new Nic();
                	link = new Link();
                    link.setHref(((Attribute)networkList.get(i)).getValue());

                    nic.setMac(((Attribute)macList.get(i)).getValue());
                    nic.setNetwork(link);
                }
            } 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] Virtual interfaces response parsed...");
        
        return ret;
    }

}