RE: How to add same children element in existing XMLfile?

"Deepa Janamatti (RBIN/EMT2)" <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Hello,
Please find below the code. This might be of some help.
 
@param duplicateNo: number of times the child has to be added or
duplicated.
@param parent: parent of the duplicate element
@param duplicateElement: child element which has to be duplicated
 
private void duplicateElement(int duplicateNo, Element parent, Element
duplicateElement){
        try{
            
            int index = parent.indexOf(duplicateElement);
            for(int i=0; i< duplicateNo; i++)
            {   
                               
                //get the contents from the parent to a local variable.
                Element parentClone = (Element)duplicateElement.clone();
                //add the modified element to the parent element
                parent.addContent(index,(Element)parentClone);

                index = parent.indexOf(duplicateElement);
                  
            }       
    
            //now remove the parent element.
            parent.removeContent(duplicateElement);            
            
        }catch (Exception e) {
           e.printStackTrace();
        }
    }
 
Regards,
Deepa

________________________________

From: [email protected]
[mailto:[email protected]] On Behalf Of Normadiah Mahiddin
Sent: Thursday, 5. April 2007 11:29 AM
To: [email protected]
Subject: [jdom-interest] How to add same children element in existing
XMLfile?


Dear all,
who knows on how to add same children element in existing XML file?
Thank you very much for your help.
 
Regards,
Normadiah Mahiddin

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.