Source Code : Java DOM edit: Copying Attributes

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Java DOM edit: Copying Attributes

      
    public void dupAttributes(Document doc) {
        Element root = doc.getDocumentElement();
        Element personOne = (Element)root.getFirstChild();
        Element personTwo = (Element)personOne.getNextSibling();
        Element personThree = (Element)personTwo.getNextSibling();

        Attr deptAttr = personOne.getAttributeNode("dept");
        personOne.removeAttributeNode(deptAttr);
        String deptString = deptAttr.getValue();
        personTwo.setAttribute("dept",deptString);
        personThree.setAttribute("dept",deptString);

        String mailString = personOne.getAttribute("mail");
        personTwo.setAttribute("mail",mailString);
        
        String titleString = personOne.getAttribute("title");
        personOne.removeAttribute("title");
        personThree.setAttribute("title",titleString);
    }


           
         
    
    
    
    
    
  

Thank with us