Merge 2 xml file using jdom

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • celiaachkar
    New Member
    • Jul 2007
    • 12

    Merge 2 xml file using jdom

    Hello everyone, i'd like to know how can I merge 2 xml files into one using jdom.
    The 2 xml files have the same structure.
    file1.xml:
    <results>
    <book>
    <title> hello1</title>
    <author< celia1</author>
    </book>
    </results>

    file2.xml
    <results>
    <book>
    <title> hello2</title>
    <author< celia2</author>
    </book>
    </results>

    I would like to obtain one file containing:

    <results>
    <book>
    <title> hello1</title>
    <author< celia1</author>
    </book>

    <book>
    <title> hello2</title>
    <author< celia2</author>
    </book>

    </results>

    Thank you for your help!!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by celiaachkar
    Hello everyone, i'd like to know how can I merge 2 xml files into one using jdom.
    The 2 xml files have the same structure.
    file1.xml:
    <results>
    <book>
    <title> hello1</title>
    <author< celia1</author>
    </book>
    </results>

    file2.xml
    <results>
    <book>
    <title> hello2</title>
    <author< celia2</author>
    </book>
    </results>

    I would like to obtain one file containing:

    <results>
    <book>
    <title> hello1</title>
    <author< celia1</author>
    </book>

    <book>
    <title> hello2</title>
    <author< celia2</author>
    </book>

    </results>

    Thank you for your help!!
    What do you have so far?
    Do you know anything about JAXP?

    Comment

    • celiaachkar
      New Member
      • Jul 2007
      • 12

      #3
      Originally posted by r035198x
      What do you have so far?
      Do you know anything about JAXP?
      No I don't. Do i absolutly need to use JAXP?

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by celiaachkar
        No I don't. Do i absolutly need to use JAXP?
        Don't be afraid of those silly (nested) acronyms. The good ol' SAX parser is even
        part of that bloated API. It's just that those W3C loonies want to move those
        bloated xml text files all over this valley or tears back and forth over and over again.

        kind regards,

        Jos

        Comment

        • celiaachkar
          New Member
          • Jul 2007
          • 12

          #5
          I'm not sure I've understood all you said. anyways do you think it is possible to merge 2 xml files that have the same structure using jdom without using xsl?

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by celiaachkar
            I'm not sure I've understood all you said. anyways do you think it is possible to merge 2 xml files that have the same structure using jdom without using xsl?
            JAXP - Java API for XML Processing

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by r035198x
              JAXP - Java API for XML Processing
              AIABA = AIABA Is Another Bloody Acronym.

              kind regards,

              Jos ;-)

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by JosAH
                AIABA = AIABA Is Another Bloody Acronym.

                kind regards,

                Jos ;-)
                There you go again

                Comment

                Working...