Merging many XML files in diff directories

I need to create a java program to merge many XML files in diff directories.
Is there any standard code to do this?

I need to create a java program to merge many XML
files in diff directories.
Is there any standard code to do this?Hi,
For a document to be well formed or a valid XML document it should have only 1 root element containing other elements.
So in case you want to merge different documents you need to create a new root element and append the child nodes of the different XML documents you want to merge excluding the first processing instruction containing the XML version and encoding.
If you are sure that these XML that you are talking about are well formed then you can achieve this by simple File I/O. create a file create write the root element and then one by one copy the contents of other xml files except the first entity if any. Finally write the closing tag of the root element and you are done.
Regards,
Rajagopal

Similar Messages

  • How to merge many XML files into one?

    Hi: I got a small project to combine many XML files into one and convert the combined XML file in Excel using AppleScript. My XML files look like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <Metadataobject>
        <from>[email protected]</from>
        <jobname>B3_IM09MBDUF</jobname>
        <pages>2</pages>
        <priority>3</priority>
        <timezone>CEST</timezone>
        <year>2013</year>
        <month>7</month>
        <day>15</day>
        <hour>11</hour>
    </Metadataobject>
    and like this...
    <?xml version="1.0" encoding="UTF-8"?>
    <Metadataobject>
        <from>[email protected]</from>
        <jobname>P1_FR1330G006007_Kate_van der Vaart</jobname>
        <pages>2</pages>
        <priority>1</priority>
        <timezone>CEST</timezone>
        <year>2013</year>
        <month>7</month>
        <day>12</day>
        <hour>16</hour>
    </Metadataobject>
    I get many XML files like this. And I want them to be combined and shown like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <Metadataobject>
        <job id="1">
        <from>[email protected]</from>
        <jobname>B3_IM09MBDUF</jobname>
        <pages>2</pages>
        <priority>3</priority>
        <timezone>CEST</timezone>
        <year>2013</year>
        <month>7</month>
        <day>15</day>
        <hour>11</hour>
        </job>
        <job id="1">
        <from>[email protected]</from>
        <jobname>P1_FR1330G006007_Kate_van der Vaart</jobname>
        <pages>2</pages>
        <priority>1</priority>
        <timezone>CEST</timezone>
        <year>2013</year>
        <month>7</month>
        <day>12</day>
        <hour>16</hour>
        </job>
    </Metadataobject>
    And finally the combined XML file converts in Excel sheet with column headings "Job ID", "From", "Job Name" and so on...
    Or there is another best way to get the same result...
    Thanks

    That is just an intermediary state to get to the excel version. Actually I get many small XML files (as shown above) from client and I want them all combined in an excel sheet with common column headings... like this...
    from
    jobname
      pages
    priority
    timezone
    year
    month
    day
    hour
    id
    [email protected]
    B3_IM09MBDUF
       2
    3
    CEST
    2013
    7
    15
    11
    1
    [email protected]
    B3_IM09MBDUF
       2
    3
    CEST
    2013
    7
    15
    11
    2
    Thanks for your response.

  • How to Merge multiple XML  files in one file ( Env: XML Publisher 5.6.2)

    All,
    I have recently started working on XML publisher and have developed 3 reports in last 2 days using XML Publisher and integrating them with Concurrent programs.
    This is a great tool.
    I have got another requirement, where i need to use xml file generated by multiple run of same report with various parameters and then merge all xml file to a single report. Developing the whole custom process will take very long time and sure will have bugs in it. Instead i was thinking to use xml file generated by Oracle report itself.
    Report "US Gross to net summary" generates xml output in standard output directory and then show output in PDF file. I have 7 such file generated for each payroll. I want to merge output of xml into a single xml so that i can create single report having data from all 7 xml files showing me All payroll output in a single report.
    Can someone please guide me , how can i read xml file data from the output directory of a seeded concurrent program and how to manipulate data in it.
    Thanks
    Ankur

    Hi Tim,
    Thanks for replying. I have looked for "PDFBookBinder class" in xml publisher user guide for ver 5.6.2. I didn't get any reference of this text. Can you please guide me to a tutorial/link where i can get more information about this class.
    Also, i originally thought of similar to your second logic, as my design basis. Oracle process generates the xml file in output directory which i can get. What i didn't get is how do i "pick them up and merge" using publisher. Also, is there way to do this merging process using pl/sql ? Can you please give little more information on your second approach.
    My original plan of action is that i will create a report set in which i will call oracle seeded report for all 7 payrolls in a sequential manner. Then using the child requests of the report set i will get to 7 xml files generated by seeded oracle process. Then the piece i am not sure of , i will use those 7 files to generate a single xml file having payroll name as tree top for each output. Once single xml is ready, i can easily design a template and register the process to generate output as Excel.This process will not require me to actually change any data or do any calculation. It will only reformatting the feilds we see and abiity to see all 7 payroll at one time rather then entering these numbers manually into an excel to do analysis.
    Please provide your feedback, if you think above plan is not feasible or need corrections.
    Best Regards,
    Ankur

  • Merge two XML files From java

    hi,
    i'm in need to merge two XML files from my java code please help me as soon......

    Rajesh42 wrote:
    hi,
    i'm in need to merge two XML files from my java code please help me as soon......Hello Rajesh42,
    While it is wonderful that you have discovered the magically code tags, please consider if it is the right time to use them. Code tags should only go round code. Note used to make your posts "stand out", or used to quote other people. Just code.
    As to your question, what have you tried, what are you stuck on?
    Mike

  • Merging two xml files into single xml file

    i hav to merge 2 xml files in to single xml file
    my xml files are
    input1.xml
    <?xml version="1.0"?>
    <PreVCD>
    <component name="stack">
    <subpath path="stack_environment">
    <variable var="ins" symbol="!" wireonbus="1"/>
    </subpath>
    </component>
    <dump>
    <time t="0">
    <data>
    <symbol sign="!" value="0"/>
    </data>
    </time>
    <time t="10">
    <data>
    <symbol sign="!" value="1"/>
    </data>
    </time>
    <time t="25">
    <data>
    <symbol sign="!" value="0"/>
    </data>
    </time>
    </dump>
    </PreVCD>
    input2.xml
    <?xml version="1.0"?>
    <PreVCD>
    <component name="stack">
    <subpath path="stack_behavior">
    <variable var="i" symbol="@" bussize="1"/>
    </subpath>
    </component>
    <dump>
    <time t="0">
    <data>
    <symbol sign="@" value="0"/>
    </data>
    </time>
    <time t="5">
    <data>
    <symbol sign="@" value="1"/>
    </data>
    </time>
    <time t="10">
    <data>
    <symbol sign="@" value="0"/>
    </data>
    </time>
    <time t="20">
    <data>
    <symbol sign="@" value="1"/>
    </data>
    </time>
    </dump>
    </PreVCD>
    The ouput should look like:
    <PreVCD>
    <component name="stack">
    <subpath path="stack_behavior">
    <variable var="i" symbol="@" bussize="1"/>
    </subpath>
    <subpath path="stack_environment">
    <variable var="ins" symbol="!" wireonbus="1"/>
    </subpath>
    </component>
    <dump>
    <time t="0">
    <data>
    <symbol sign="@" value="0"/>
    <symbol sign="!" value="0"/>
    </data>
    </time>
    <time t="5">
    <data>
    <symbol sign="@" value="1"/>
    </data>
    </time>
    <time t="10">
    <data>
    <symbol sign="@" value="0"/>
    <symbol sign="!" value="1"/>
    </data>
    </time>
    <time t="20">
    <data>
    <symbol sign="@" value="1"/>
    </data>
    </time>
    <time t="25">
    <data>
    <symbol sign="!" value="0"/>
    </data>
    </time>
    </dump>
    </PreVCD>
    thanks for any advice

    Merge xml documents with the xslt document() function.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" />
    <xsl:template match="/">
    <xsl:copy-of select="*"/>
    <xsl:copy-of select="document('input2.xml')"/>
    </xsl:template>
    </xsl:stylesheet>

  • IDCS6 MACOSX JS: Data Merging many txt files one after another

    Hello everybody.
    I have a situation where I have to data-merge many text files to the one actual indesign "base" file. The formats of the databases are all the same, the point of difference is a code in the second field of the database that refers to a mailing zone (not a zip/postcode, a "distribution centre" code that has 56 or so possibilities). I would prefer to data merge one file and then somehow split the resulting PDF via Acrobat, but the length of the resulting mailing zones is inconsistent and something that can't be done though the "split document" feature in acrobat.
    The database starts out as one massive file but using a one-line  code, can be split into its mailing zones into separate text files.
    My ultimate question: is there any way to data merge more than one file at once (e.g. one after another) and give them their names based on the names of the input text file?
    Ole Kvern had a script to Data Merge one file without the UI. I have altered the last line slightly so that it outputs to a PDF based on [High Quality Setting]:
    if(app.documents.length != 0){
            var myDocument = app.activeDocument;
            app.dataMergeOptions.removeBlankLines = true;
            //Select a source file.
            var myDataFile = File.openDialog("Select a data file")
            var exported = "file location(redacted for the sake of this post)"
            if(myDataFile != ""){
                    myDocument.dataMergeProperties.selectDataSource(myDataFile,);
                    myDocument.dataMergeProperties.exportFile(exported,"[High Quality Print]",);
    I figure the answer has to do with the variable "myDataFile" and rather than being simply open a dialog, it would be somehow selecting an array of text files, but this is where I am out of my depth.
    Any insights or other thoughts that may not involve trying to do many merges at once but may somehow revolve around one large merged PDF?
    Many thanks
    Colin

    I've answered my own question, but the answer lies outside of Adobe InDesign – it uses bookmarks within Adobe Acrobat.
    1) Data Merge the art/data to one large PDF file.
    2) In the resulting PDF file, manually search out the mailing zones and apply bookmarks to each first instance only of each mailing zone. In this case, it is a manual process of find/replace to find one of 70 possible mailing zones that may be used in any database. Each bookmark should be named with its respective code. It is a manual process, but it would take 5 minutes so this is acceptable.
    3) Using "Split Document" from the pages panel, make sure the "top level bookmarks" radio button is checked, and in the Output Options make sure that the "Use bookmark names for files" radio button is checked.
    I'm aware that this was a rather obscure question that only a fraction of users on this forum may wish to know an answer for, but hopefully this workaround helps someone else in a similar situation.
    Colin

  • How to merge portlet.xml file from shared libraries into an EAR application

    Hi all
    I need some help
    I have some applications as shared-libs referenced by weblogic.xml into a EAR application.
    To see all portlets from that shared-libs, I'm creating a portlet.xml into the EAR application with all portlets from all shared libs. But is terrible for me. I would like to have it merged automatically without having to create it in the EAR application. Is that possible?
    Regards
    Bruno

    In the documentation, I saw this text:
    Overriding Shared J2EE Library Settings in the web.xml File
    At runtime, the web.xml files in all the shared J2EE libraries are merged, along with the web.xml
    file in your portal web project. The content of your WEB-INF/web.xml file overrides anything in
    the shared J2EE libraries, so if you want to change particular settings, you can do it there.
    There are many other files for which file contents are merged; these can be overridden in the same
    way. These files include not only WEB-INF/web.xml but also WEB-INF/weblogic.xml and any
    files mentioned in weblogic-extension.xml from either the users' application or the shared
    libraries.
    It seems to be possible to customize the weblogic-extension.xml. But I haven't seen how to do that
    What do you think about it?
    Regards
    Bruno

  • Recursively Merging 2 XML files with XSLT

    Hi there, I'm having a problem with merging a couple of XML files. I've found a few examples of merging on-line but none that really help.
    Basically I have an XML file which is written out by my Java program that looks something like this:
    <alldata>
       <data val="xx">
          <data val="yy">
             <data val="ss"></data>
          </data>
       <data val="gg"></data>
    </alldata>The number of children and siblings can change by the way.
    Therefore in the XSLT document I'm displaying the data recursively, i.e.
    <tr><td><xsl:value-of select="@val"/></td></tr>
    <xsl:for-each select="*">
       <xsl:call-template name="itself"></xsl:call-template>
    </xsl:for-each>This all works fine, but I now need to do a side by side comparison with another XML document that has exactly the same structure, but could have different values. I'm not sure how to do this, perhaps using the same recursive code and using a sort of pointer to where you are in the 2nd XML file (see below), but I've no idea how to go about this?
    <tr><td><xsl:value-of select="@val"/></td>
           <td><xsl:value-of select="<2nd documents @val>"/></td>
    </tr>
    <xsl:for-each select="*">
       <xsl:call-template name="itself"></xsl:call-template>
    </xsl:for-each>Output:
    xx    xy
    yy    yy
    ss   ss
    gg   hhDoes anybody have any suggestions or help on how to achieve this?
    Cheers
    Dan

    I posted the same question on the xsl-list message list and got a working solution - here it is in case anyone else has the same problem:
    <xsl:variable name="a" select="document('doc1.xml')//data"/>
    <xsl:variable name="b" select="document('doc2.xml')//data"/>
    <xsl:template match="/">
         <table>
           <xsl:for-each select="$a">
             <xsl:variable name="p" select="position()"/>
             <tr>
               <td><xsl:value-of select="@val"/></td>
               <td><xsl:value-of select="$b[$p]/@val"/></td>
             </tr>
           </xsl:for-each>
         </table>
    </xsl:template>Cheers
    Dan

  • Merging X XML files, sorting the resultlist and finally execute a distinct?

    I have several questions about an XSLT file that I should write:
    1� First, I get X paths to XML files. It can be 2, 3, 4, ... whatever a number. I don't know exactly the total amount of XML files.
    I need to merge them dynamicly to one resultset.
    2� Next, I need to sort them on a specific node (remark: every XML file has the same DOM tree)
    3� Finally, I want to distinct the values because some of the nodes are in file 1, 2, 3 ... So I don't want duplicates.
    I guess this is not possible in XSLT? I can't use Java, so it should be done using XSLT ;;;

    Have a look here:
    [http://www.jenitennison.com/xslt/index.html|http://www.jenitennison.com/xslt/index.html]
    under the "Sorting" and "Grouping" sections. Also consider using XSLT 2.0, which has built-in grouping elements which make the convoluted XSLT 1.0 techniques unnecessary.

  • Merge Two Xml files ????

    I have two xml files, which I want to merge.
    Both are having same structure�
    Eg. *INPUT-FILE-1*
    <library>
         <book isbn="1">
              <name>Book-11</name>
              <author>steve</author>
              <price>2.99</price>
         </book>
              <book isbn="2">
              <name>Book-22</name>
              <author>john</author>
              <price>12.99</price>
         </book>
    </library>
    *INPUT-FILE-2*
    <library>
         <book isbn="1">
              <name>Book-11</name>
              <author>steve</author>
              <price>2.99</price>
         </book>
              <book isbn="3">
              <name>Book-33</name>
              <author>johnthan</author>
              <price>12.99</price>
         </book>
    </library>
    *OUTPUT-file*
    <library>
         <book isbn="1">
              <name>Book-11</name>
              <author>steve</author>
              <price>2.99</price>
         </book>
              <book isbn="2">
              <name>Book-22</name>
              <author>john</author>
              <price>12.99</price>
         </book>
    </book>
              <book isbn="3">
              <name>Book-33</name>
              <author>johnthan</author>
              <price>12.99</price>
         </book>
    </library>Merge should provide third file without any repetition of any record.
    Which parser to use and how to use ???
    Any help on this ???????????
    Thanks !!

    Merge should provide third file without any repetition of any record.
    Which parser to use and how to use ???Look at JDOM
    Any help on this ???????????One question mark is all that is necessary.

  • How can I open the selected many xml files at one time in framemaker?

    I want to open the selected xml files at one time in framemaker,but it allows to select one xml file at one time,if i want to select many files ,
    How can i to do?

    Please repost in the FrameMaker forum.
    Mike

  • Problem in adding many xml files at time of addon creation from AddonCreato

    Hi,
        When creating addon by SAP B1 addoninstaller .Net wizard,we have to add XML Files one by one which is very difficult to do because my addon have more than 60 XML files.
    Please give me any solution so that we do not have to add again and again all XML Files.
    Thanks
    Vivek Kr. Gaurav

    Pl post this question to SDK Forum

  • One to many xml files with file adaptor

    Hi,
    I have a scenario HCM-ABAPProxy--XI-File for one structure I need to generate multiple xml files with 100 records per file.
    this is my input  messag
    MT_in
      Node
         PositionIDs
            descrption
            job
            IsActive
    what I was doing on the ABAP side for every node I have 100 PositionID's sub nodes. so each node should be a sperate file.
    my output structure is
    PositionIDs
        PositionID
          pid
          description
          job
    so there should be one PositionIDs per file which contains 100 PositionID.
    I've multi message mapping without BPM that did not work out just wondering if any one came across the same scenario.
    thanks,
    Joe

    You can not create multiple files without BPM. You can pretty much perform multi mapping to achieve your split but to write it to a file, you will have to call the file adapter for each split which you can not do without using BPM. In BPM, for each split that you perform, you can use a send step in for-each loop which will give you the functionality you require.
    Award if helpful,
    Sarath.

  • Merge Many PDF files in several PDF Files

    Hi,
    I have about 500 PDF Files :
    PDF_A1
    PDF_A2
    PDF_B1
    PDF_B2
    EtC.
    I want to Merge all my 500 PDF Files in 250 PDF files. I want to merge A1 with A2. B1 with B2 etc. Any idea to how to do ?
    Thank you

    Hi Dave,
    First, the issue does not exist anymore. We have decided to merge all documents in the same file. that's done and OK
    Then, Any way, I have found a solution:
    Use a script to put in different folders all files which must be together. I mean Folder A will contain files A1 and A2. Folder B will contain files B1 and B2 ...
    Then use a PDF software in command line to merge all PDF files folder by folder.
    Thnak you for your reply.

  • Spry deal with many xml files

    Hi guys!
    I have a problem about "Spry.Data.XMLDataSet",
    I have two xml files, "em1.xml" and "em2.xml". they have the
    same structure;
    The code of "em1.xml" :
    <employees>
    <employee id="123456">
    <lastname>Smith</lastname>
    <firstname>Edward</firstname>
    <phone>(415) 333-0235 </phone>
    <username>esmith</username>
    </employee>
    <employee id="127937">
    <lastname>Johnson</lastname>
    <firstname>Neil</firstname>
    <phone>(415) 333-9475 </phone>
    <username>njohnson</username>
    </employee>
    </employees>
    and the "em2.xml" code:
    <employees">
    <employee id="123543">
    <lastname>Davis</lastname>
    <firstname>Kirk</firstname>
    <phone>(415) 333-4334 </phone>
    <username>kdavis</username>
    </employee>
    <employee id="127944">
    <lastname>Miller</lastname>
    <firstname>James</firstname>
    <phone>(415) 333-7566 </phone>
    <username>jmiller</username>
    </employee>
    </employees>
    Now! I want to display these datas on a dynamic table.here is
    my code
    var ds1 = new Spry.Data.XMLDataSet("em1.xml",
    "employees/employee");
    var ds2 = new Spry.Data.XMLDataSet("em2.xml",
    "employees/employee");
    var ds3 = new Spry.Data.XMLDataSet();
    ds3.data = ds1 + ds2;
    <div spry:region="ds3">
    <ul spry:repeatchildren="ds3">
    <li spry:sort="lastname">{lastname}</li>
    </ul>
    </div>
    finally! But It does not work! How can I combine "ds1" and
    "ds2"!
    ------

    on my God! Spry have not support the method!
    but I've solved it;
    my code:
    var ds1 = new Spry.Data.XMLDataSet("em1.xml",
    "employees/employee");
    var ds2 = new Spry.Data.XMLDataSet("em2.xml",
    "employees/employee");
    ds1.loadData();
    ds2.loadData();
    //ds2 addObserver
    var myObj = new Object;
    myObj .onPostLoad = function(dataSet,data){
    dataSet.data = dataSet.data.concat(ds1.data);//concat two
    array
    for(var i=0; i<dataSet.data.length; i++){
    dataSet.data
    .ds_RowID = i;//reset ds_RowID
    ds2.addObserver(myObj );

Maybe you are looking for

  • How to add item in advnace search LOV  of OA frame work ?

    HI, I have one requirement to add one new item in existing lov of advance search of vertical view in OA framework which is seeded.Through the Form personalisation I have created Criteria Row: (MscCreationdate_row) in which i have given ID value as Ms

  • I upgraded to Firefox 4 and lost my Identity Safe w/ Norton. How can I get it back?

    ''Locking, as this problem has been fixed by Norton - [http://us.norton.com/support/kb/web_view.jsp?wv_type=public_web&docurl=20100720112959EN&pvid=nis-2011&selected_nav=5&layout= see this Norton support page.] Identity Safe is a part of Norton and i

  • [HOWTO] Mplayer music daemon

    Hello fellow Archers, I recently noticed that XMMS2 was using 40% of my CPU (not sure how I missed it but it no doubt has something to do with my setup) and decided I needed to correct this. My plan was to initially write my own music server, but tha

  • Fail to ping to Solaris 10 system.

    I install Solaris 10 but sometime I could not ping to system but sometime it is ok to ping. Is there any problem with network configuration in Solaris 10 or it is a network environment because I rent my server in the share rack (Data Center) and I do

  • Multi-consumer queue table does not empty

    Hello, I must be missing something pretty trivial here but I have setup queue with a queue table where multiple_consumers = true. When I dequeue a message from the queue it is received, but the message is still left in the queue table. When I do a se