[jdom-interest] How to build multiple XML documents by mergeing two XML documents using JDOM

Jasmin_Mehta at nexweb.org Jasmin_Mehta at nexweb.org
Fri Nov 23 07:12:25 PST 2007

I am building multiple dynamic xml documents from result set and storing 
them to an ArrayList called 'xmlDocumentList'.
I have another static xml document called 'staticDocument'. Where static 
document looks like:

              <UserName />
              <Password />
      <!----- here goes GLogXMLElement XML element ---->

Now I want to create another ArrayList 'finalDocumentList' out of mergeing 
'staticDocument' with each element of 'xmlDocumentList'. That will be like 
each element of 'finalDocumentList' is made from merging 'staticDocument' 
with 'xmlDocumentList[i]' (one of dynamic document element) at 
<TransmissionBody>. When I do that with attached code snippet, it creates 
the GlogFinal0.xml, GlogFinal1, GlogFinal2..etc file with all having same 
content in them. It uses only first element of 'xmlDocumentList' to build 
all elements of 'finalDocumentList'.

        ArrayList dynamicDocumentList = 
        Document staticDocument = xmlBuilder.getStaticXmlWrapper();
        ArrayList finalDocumentList = new ArrayList(); 
        Element staticRoot = staticDocument.getRootElement();
        Element staticChild = staticRoot.getChild("TransmissionBody");
        Element dynamicRoot = null;
        for(int i = 0; i < dynamicDocumentList.size(); i++)
            dynamicRoot = 
          FileOutputStream finalXmlFile = null;
          XMLOutputter xmlOutPutter = null;
          for (int i = 0; i < finalDocumentList.size(); i++)
            finalXmlFile =  new 
            xmlOutPutter = new XMLOutputter(Format.getPrettyFormat());
Our domain name is changing.  Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed.  Both domains will continue to work, only for a limited
This email and any files transmitted with it are intended solely for 
the use of the individual or agency to whom they are addressed. 
If you have received this email in error please notify the Navy 
Exchange Service Command e-mail administrator. This footnote 
also confirms that this email message has been scanned for the
presence of computer viruses.

Thank You!            

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20071123/075806cd/attachment.htm

More information about the jdom-interest mailing list