private void parseXML() {
		Stack<XMLElement> elemStack = new Stack<XMLElement>();
		pos = 0;
		root = new XMLElement("xml");
		elemStack.push(root);
		
		String next = getNextString();
		while (!next.isEmpty()) {
			if (next.contains("?xml")) {
				next = getNextString();
				continue;
			}
			if (next.charAt(0) == '<') {
				if (next.charAt(1) != '/') {
					int namePos = next.indexOf(' ');
					if (namePos == -1)
						namePos = next.length() - 1;
					String name = next.substring(1, namePos);
					XMLElement newElem = new XMLElement(name);
					if (namePos < next.length() - 3) {						
						int newPos = namePos + 1;
						while (newPos < next.length() - 1) {
							int nextPos = next.indexOf(' ', newPos);
							if (nextPos == -1)
								nextPos = next.length() - 1;
							String attrStr = next.substring(newPos, nextPos);
							int midPos = attrStr.indexOf('=');
							String key = attrStr.substring(0, midPos);
							String value = attrStr.substring(midPos+2, attrStr.length()-1);
							newElem.attributeMap.put(key, value);
							newPos = nextPos + 1;
						}
					}
					elemStack.peek().childList.add(newElem);
					elemStack.push(newElem);
					if (next.charAt(next.length()-2) == '/')
						elemStack.pop();
				} else {
					XMLElement parentElem = elemStack.pop();
					assert(parentElem.name.equals(next.substring(2, next.length()-1)));
				}
			} else {
				elemStack.peek().content = next;
			}
			next = getNextString();
		}
	}