private Document getXmlDocument(ScrapingHistory scrappingHistory) throws ParserConfigurationException { Document result = null; if (scrappingHistory != null) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); result = docBuilder.newDocument(); Element rootElement = result.createElement("ScrappingHistory"); addAttribute( result, rootElement, PROPERTY_DATE, getDateFormat().format(scrappingHistory.getDate())); result.appendChild(rootElement); for (UrlConnectionWrapper searchConnection : scrappingHistory.getSearchConnectionList()) { Element viadeoSearchEle = result.createElement("ViadeoSearch"); rootElement.appendChild(viadeoSearchEle); addAttribute( result, viadeoSearchEle, "scrapped", searchConnection.isScrapped() ? "true" : "false"); addAttribute(result, viadeoSearchEle, PROPERTY_URL, searchConnection.getUrl()); addAttribute(result, viadeoSearchEle, PROPERTY_USERAGENT, searchConnection.getUserAgent()); addAttribute(result, viadeoSearchEle, PROPERTY_REFERER, searchConnection.getReferer()); addAttribute(result, viadeoSearchEle, PROPERTY_TIMEOUT, "" + searchConnection.getTimeout()); addAttribute( result, viadeoSearchEle, PROPERTY_METHOD, "" + searchConnection.getMethod().toString()); Element postParamListEle = result.createElement("PostParameterList"); viadeoSearchEle.appendChild(postParamListEle); for (String paramName : searchConnection.getPostParameterMap().keySet()) { String paramValue = searchConnection.getPostParameterMap().get(paramName); Element postParamEle = result.createElement("PostParameter"); addAttribute(result, postParamEle, PROPERTY_NAME, paramName); addAttribute(result, postParamEle, PROPERTY_VALUE, paramValue); postParamListEle.appendChild(postParamEle); } Element cookieListEle = result.createElement("CookieList"); viadeoSearchEle.appendChild(cookieListEle); for (String cookieName : searchConnection.getCookies().keySet()) { String cookieValue = searchConnection.getCookies().get(cookieName); Element cookieEle = result.createElement("Cookie"); addAttribute(result, cookieEle, PROPERTY_NAME, cookieName); addAttribute(result, cookieEle, PROPERTY_VALUE, cookieValue); cookieListEle.appendChild(cookieEle); } } } return result; }