private void updateScreenArea(String pngFile, Area area) throws Exception { String xmlArea = "./workspace/" + file.substring(0, file.indexOf("/")) + "/screen_area.xml"; XmlUtil xmlUtil = new XmlUtil(xmlArea); Document doc = xmlUtil.parse(xmlArea); Element root = doc.getDocumentElement(); NodeList childs = root.getChildNodes(); if (childs != null) { // del for (int i = 0; i < childs.getLength(); i++) { Node node = childs.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { NamedNodeMap map = node.getAttributes(); String fileName = map.getNamedItem("file").getNodeValue(); if (fileName.equals(pngFile)) { root.removeChild(node); break; } } } } // add Hashtable<String, String> attri = new Hashtable(); attri.put("file", area.getFile()); attri.put("x", String.valueOf(area.getX())); attri.put("y", String.valueOf(area.getY())); attri.put("width", String.valueOf(area.getWidth())); attri.put("height", String.valueOf(area.getHeight())); xmlUtil.appendNode(root.getOwnerDocument(), "area", "", attri); xmlUtil.flush(doc); }