CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Merge XML File

  1. #1
    Join Date
    Mar 2002
    Posts
    50

    Merge XML File

    I have 2 XML files with same DTD ,i want to merge both the XML files,through VB

    Thanks in advance

    Regards
    Nit

  2. #2
    Join Date
    Apr 2002
    Posts
    388
    Use the DOM!

    The steps should be:

    Code:
    Create DOMDocument of the first XML File.
    Create DOMDocument of the second XML File.
    Create new DOMDocument
    
    For each Element in the First DOMDocument
       add this Element to the new DOMDocument
    next Element
    
    For each Element in the Second DOMDocument
       add this Element to the new DOMDocument
    next Element
    
    Save the new Document
    Try to implement this steps. If there special questions post them!
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  3. #3
    Join Date
    Mar 2002
    Posts
    50
    Thats fine but what if both files have same record?

  4. #4
    Join Date
    Apr 2002
    Posts
    388
    Try this:
    Code:
    Create DOMDocument of the first XML File.
    Create DOMDocument of the second XML File.
    Create new DOMDocument
    
    'add all elements of the first DOMDocument
    For each Element in the First DOMDocument 
       add this Element to the new DOMDocument
    next Element
    
    'add those elements of the second that are not in the first
    for each Element in the Second DOMDocument
       check if this element in the first DOMDocument by compare with each Element if it
    
       if not found in first DOMDocument
          add this element to the new DOMDocument
       endif
    next Element
    
    save the new DOMDocument
    hope this helps...
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured