public static void write() {
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		try {
			DocumentBuilder builder = dbf.newDocumentBuilder();
			InputStream in = TestDom.class.getClassLoader()
					.getResourceAsStream("test.xml");
			Document doc = builder.parse(in);
			// root <university>
			Element root = doc.getDocumentElement();
			if (root == null)
				return;
			// ޸
			root.setAttribute("name", "tsu");
			NodeList collegeNodes = root.getChildNodes();
			if (collegeNodes != null) {
				for (int i = 0; i < collegeNodes.getLength() - 1; i++) {
					// ɾڵ
					Node college = collegeNodes.item(i);
					if (college.getNodeType() == Node.ELEMENT_NODE) {
						String collegeName = college.getAttributes()
								.getNamedItem("name").getNodeValue();
						if ("c1".equals(collegeName)
								|| "c2".equals(collegeName)) {
							root.removeChild(college);
						} else if ("c3".equals(collegeName)) {
							Element newChild = doc.createElement("class");
							newChild.setAttribute("name", "c4");
							college.appendChild(newChild);
						}
					}
				}
			}
			// ڵ
			Element addCollege = doc.createElement("college");
			addCollege.setAttribute("name", "c5");
			root.appendChild(addCollege);
			Text text = doc.createTextNode("text");
			addCollege.appendChild(text);

			// ޸ĺĵ浽ļ
			TransformerFactory transFactory = TransformerFactory.newInstance();
			Transformer transFormer = transFactory.newTransformer();
			DOMSource domSource = new DOMSource(doc);
			File file = new File("src/dom-modify.xml");
			if (file.exists()) {
				file.delete();
			}
			file.createNewFile();
			FileOutputStream out = new FileOutputStream(file);
			StreamResult xmlResult = new StreamResult(out);
			transFormer.transform(domSource, xmlResult);
			System.out.println(file.getAbsolutePath());
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (TransformerConfigurationException e) {
			e.printStackTrace();
		} catch (TransformerException e) {
			e.printStackTrace();
		}
	}