public static Message getMessageByXMLElem(XMLElement root) {
		if (!root.attributeMap.containsKey("type")) {
			System.out.println("Message type must have a 'type' field");
			return null;
		}
		
		String type = root.attributeMap.get("type");
		if (type.equals("challenge")) {
			return ChallengeMessage.getChallengeMessageByXMLElem(root);
		} else if (type.equals("friend-request")) {
			return FriendRequestMessage.getFriendRequestByXMLElem(root);
		} else if (type.equals("note")) {
			return NoteMessage.getNoteMessageByXMLElem(root);
		} else {
			System.out.println("Unrecognized message type " + type);
			return null;
		}
	}