@Override
	public String generate(AbstractChatResponse message, String type) {
		String xmlString = "";

		// build XML
		try {
			DocumentBuilderFactory docBFac = DocumentBuilderFactory.newInstance();
			DocumentBuilder docBuilder = docBFac.newDocumentBuilder();
			
			Document doc = docBuilder.newDocument();
			
			Element root = doc.createElement("lanchat");
			root.setAttribute("version", version);
			

			if(!type.equals("message") && !type.equals("ping"))
					throw new IllegalArgumentException("type must be message or ping : ");
			
			root.setAttribute("type", type);
			
			Element msg = null;
			if(type.equals("message")) {
				msg = doc.createElement("message");
				// disallow own html tags
				String filteredMsg = StringUtil.stripHtmlTags(message.getChatMessage().getMessage());
				msg.appendChild(doc.createTextNode(filteredMsg));
				
				Element date = doc.createElement("tstamp");
				date.appendChild(doc.createTextNode("" + message.getWritten().getTime()));
				root.appendChild(date);
			}
			
			
			
			Element from = doc.createElement("from");
			from.appendChild(doc.createTextNode(message.getChatName().getName()));
			root.appendChild(from);
			
			
			if(type.equals("message"))
				root.appendChild(msg); 
			
			Element id = doc.createElement("id");
			id.appendChild(doc.createTextNode("" + message.getID()));
			//id.appendChild(doc.createTextNode("" + SLCP.getMacAddressHash()));
			
			
			root.appendChild(id);
			
			doc.appendChild(root);
			
			
			//set up a transformer
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.INDENT, "no");
            trans.setOutputProperty(OutputKeys.ENCODING, ENCODING.toString());
            trans.setOutputProperty(OutputKeys.STANDALONE, "yes");
            
            
            //create string from xml tree
            StringWriter sw = new StringWriter();
            StreamResult result = new StreamResult(sw);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            
            xmlString = sw.toString();
			
            
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
			
		} catch (TransformerException e) {
			e.printStackTrace();
		}
		
		return xmlString;
	}