public void addAttribute(Document doc) { Element root = doc.getDocumentElement(); Element person = (Element)root.getFirstChild(); person.setAttribute("company","CastleWorks"); }