public static void writeElementEnd(
		StringBuffer buf, 
		int depth,
		String line_ending, 
		String name
	) throws IllegalArgumentException {
		if (isValidXMLElementName(name)) {
			indent(buf, depth);
			buf.append("</").append(name).append(">");
			if (line_ending != null) {
				buf.append(line_ending);
			}
		} else {
			throw new IllegalArgumentException("Invalid element name: " + name);
		}
	}