merge two xml file of the same structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lttan123
    New Member
    • Oct 2008
    • 11

    merge two xml file of the same structure

    I have two xml files with the same structure
    file1
    <Topic>
    <Child>
    <wpf>
    <Child>
    <learn>
    <Child>
    </Child>
    <Link>
    <url>http://1.com</url>
    </Link>
    </learn>

    <animation>
    <Child>
    </Child>
    <Link>
    <url>www.2.co m</url>
    </Link>
    </animation>
    </Child>
    <Link>
    <url>www.1up.co m</url>
    <url>www.2up.co m</url>
    </Link>
    </wpf>
    <csharp>
    <Child></Child>
    <Link></Link>
    </csharp>
    </Child>
    <Link>
    </Link>
    </Topic>

    File 2
    <Topic>
    <Child>
    <wpf>
    <Child>
    <learn>
    <Child>
    </Child>
    <Link>
    <url>http://windowsclient.n et/learn/video.aspx?v=55 062</url>
    </Link>
    </learn>
    </Child>
    <Link>
    </Link>
    </wpf>
    </Child>
    <Link>
    </Link>
    </Topic>

    How do i merge the two files so that the learn part looks like this

    <learn>
    <Child>
    </Child>
    <Link>
    <url>http://1.com</url>
    <url>http://windowsclient.n et/learn/video.aspx?v=55 062</url>
    </Link>
    </learn>
  • SvenV
    New Member
    • Oct 2008
    • 50

    #2
    Doesn't look like the same structure to me. In the first file you have some different tags

    Comment

    • lttan123
      New Member
      • Oct 2008
      • 11

      #3
      File 1
      <Contents version="0.8">
      <Tag name="WPF">
      <Children>
      <Tag name="Visual Basic">
      <Children></Children>
      <Links>
      <link source="http://www.yahoo.com" title="YAHOO"></link>
      <link source="http://www.google.com" title="GOOGLE"> </link>
      <link source="http://www.live.com" title="LIVE"></link>
      <link source="http://www.hello.com" title="Hello"></link>
      </Links>
      </Tag>
      </Children>

      <Links>
      <link source="http://www.yahoo.com" title="YAHOO"></link>
      <link source="http://www.google.com" title="GOOGLE"> </link>
      <link source="http://www.live.com" title="LIVE"></link>
      </Links>
      </Tag>
      </Contents>

      file 2
      <Contents version="0.8">
      <Tag name="WPF">
      <Children>
      <Tag name="Visual Basic">
      <Children></Children>
      <Links>
      <link source="http://www.abc.com" title="YAHOO"></link>
      <link source="http://www.google.com" title="GOOGLE"> </link>
      <link source="http://www.live.com" title="LIVE"></link>
      <link source="http://www.hello.com" title="Hello"></link>
      </Links>
      </Tag>
      <Tag name="C#">
      <Children></Children>
      <Links>
      <link source="http://www.yahoo.com" title="YAHOO"></link>
      <link source="http://www.google.com" title="GOOGLE"> </link>
      <link source="http://www.live.com" title="LIVE"></link>
      </Links>
      </Tag>
      </Children>

      <Links>
      <link source="http://www.yahoo.com" title="YAHOO"></link>
      <link source="http://www.google.com" title="GOOGLE"> </link>
      <link source="http://www.live.com" title="LIVE"></link>
      </Links>
      </Tag>
      </Contents>
      i would want the result to be something like this
      <Tag name="Visual Basic">
      <Children></Children>
      <Links>
      <link source="http://www.yahoo.com" title="YAHOO"></link>
      <link source="http://www.google.com" title="GOOGLE"> </link>
      <link source="http://www.live.com" title="LIVE"></link>
      <link source="http://www.hello.com" title="Hello"></link>
      <link source="http://www.abc.com" title="YAHOO"></link>

      </Links>
      </Tag>

      Comment

      Working...