public synchronized void checkActivationCodeInXML(String code, String attrType) throws Exception
	{
		/* NOTE: THIS FUNCTION IS SYNCHRONIZED, ONLY ONE CLIENT HAS ACCESS TO THE XML FILE AT ANY GIVEN TIME, OTHERS WILL HAVE TO WAIT */

		if(null == code)
		{
			throw new IllegalArgumentException("The activation code provided is 'null'...");
		}

		if(code.isEmpty() || code.length() != sv.ACTIVATION_CODE_LENGTH)
		{
			throw new Exception("The activation code must be exactly " + sv.ACTIVATION_CODE_LENGTH + " characters long");
		}

		File codeBase = new File(sv.ACTIVATION_CODES_XML_FILE_LOCATION);

		synchronized(sv)
		{
			sv.quizLogger.log(Level.INFO, "Loading " + sv.ACTIVATION_CODES_XML_FILE_LOCATION + " for validating activation code, " + code + "...");
		}

		if(codeBase.exists())
		{
			// setup the DOM APIs
			DocumentBuilderFactory codesFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder codesBuilder = codesFactory.newDocumentBuilder();
			Document codesDoc = codesBuilder.parse(codeBase);

			// try to find the activation code in the XML

			// create a list of all "code" tags
			NodeList codesNodeList = codesDoc.getElementsByTagName("code");

			Element codeWalker;
			String nowCode;

			// linearly search for the activation code
			for(int i = 0; i < codesNodeList.getLength(); i++)
			{
				// get an item one by one
				codeWalker = (Element) codesNodeList.item(i);

				// get the attribute
				nowCode = codeWalker.getAttribute("value");

				// search linearly thru the database for the given code, case ignored
				if(0 == nowCode.compareToIgnoreCase(code))
				{
					// if attrType is takenQuiz, first check whether they've logged in using that code
					// this happens when, they log in with one valid activation code and they submit the answers with another valid activation code
					if(0 == attrType.compareToIgnoreCase("takenQuiz"))
					{
						if(0 == (codeWalker.getAttribute("loggedIn")).compareToIgnoreCase("no"))
						{
							break; // break and fall down and throw the  Execption below
						}
					}

					// check if that code was used to log in/take quiz once already
					if(0 == (codeWalker.getAttribute(attrType)).compareToIgnoreCase("yes"))
					{
						// the activation code was already used, so break and fall down and throw the Exception below
						break;
					}

					// if everything went well, set the loggedIn/takenQuiz flag to yes, so that the code won't be used again
					codeWalker.setAttribute(attrType, "yes");
					
					// write everything to file
					// setup the transformer APIs
					TransformerFactory codesTransformerFactory = TransformerFactory.newInstance();
					Transformer codesTransformer = codesTransformerFactory.newTransformer();

					codesTransformer.setOutputProperty(OutputKeys.INDENT, "yes");

					// source is this DOM object
					DOMSource codesSource = new DOMSource(codesDoc);

					// destination is the standard output on the server
					StreamResult codesDest =  new StreamResult(codeBase);

					// perform the transformation ie write to file
					codesTransformer.transform(codesSource, codesDest);

					// then silently return from the function, without raising any exceptions
					return;
				}
			}

			// if u parse thru the database and don't find the code, then we have a problem!
			throw new Exception("This activation code that you've entered is invalid.");
		}
		else
		{
			throw new FileNotFoundException(sv.ERROR_FILE_NOT_FOUND);
		}
	}