static void test4()
		throws HtmlException, IOException
	{
		Reader in = new StringReader(
			"</html>\n"+
			"<?XML version=\"1.0\" encoding=\"UTF8\" ?>\n"+
			"<!DOCTYPE>\n"+
			"<IMG/>\n"+
			"<IMG src=a.gif / >\n"+
			""
			);

		HtmlStreamTokenizer tok = new HtmlStreamTokenizer(in);
		HtmlTag tag = new HtmlTag();
		while (tok.nextToken() != HtmlStreamTokenizer.TT_EOF)
		{
			StringBuffer buf = tok.getWhiteSpace();
			if (buf.length() > 0)
				System.out.print(buf.toString());

			if (tok.getTokenType() == HtmlStreamTokenizer.TT_TAG)
			{
				try
				{
					tok.parseTag(tok.getStringValue(), tag);
					if (tag.getTagType() == HtmlTag.T_UNKNOWN)
						throw new HtmlException("unkown tag");
					if (tag.isEmpty())
						System.out.print("EMPTY ");
					System.out.print(tag.toString());
				}
				catch (HtmlException e)
				{
					// invalid tag, spit it out
					System.out.print("\ninvalid: ");
					System.out.print("<" + tok.getStringValue() + ">");
					System.out.println("");
				}
			}
			else
			{
				buf = tok.getStringValue();
				HtmlStreamTokenizer.unescape(buf);
				if (buf.length() > 0)
					System.out.print(buf.toString());
			}
		}
	}