Merging 2 XML documents in Java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luthriaajay
    New Member
    • Apr 2007
    • 56

    #1

    Merging 2 XML documents in Java

    I have a tricky situation,
    So please any help will be appreciated.

    I have 2 XML docs :

    Code:
    Document 1
    ----------
    <Interest>
    <Status>1</Status>
    </Interest>
    
    Document 2
    ----------
    <Under value="ABC>
    <comm:Desc>Daimler</comm:Desc>
    </Under>

    I need to add both of them as a single document so that the output XML looks like

    Code:
    <Interest>
    <Status>1</Status>
    
    <Under value="ABC>
    <comm:Desc>Daimler</comm:Desc>
    </Under>
    
    </Interest>
    How do I use the Class DOMSource in Java? Is this possible please?
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    Hi,

    It seems that the answer requires more Java help, so I'll move the thread to Java forum.

    Dorin.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by luthriaajay
      I have a tricky situation,
      So please any help will be appreciated.

      I have 2 XML docs :

      Code:
       
      Document 1
      ----------
      <Interest>
      <Status>1</Status>
      </Interest>
       
      Document 2
      ----------
      <Under value="ABC>
      <comm:Desc>Daimler</comm:Desc>
      </Under>

      I need to add both of them as a single document so that the output XML looks like

      Code:
       
      <Interest>
      <Status>1</Status>
       
      <Under value="ABC>
      <comm:Desc>Daimler</comm:Desc>
      </Under>
       
      </Interest>
      How do I use the Class DOMSource in Java? Is this possible please?
      I would use JAXP for this and manually add the Under tag from the second XML file to the interest tag of the first XML file.

      Comment

      Working...