XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] merge 2 xml file in c#

You've left out some start tags, but I assume that's irrelevant.
 
Why would you want to program such a simple task in a low-level language?
 
It's dead easy in XSLT:
 
<ResultsCollection xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:copy-of select="document('a.xml')/*/*"/>
 <xsl:copy-of select="document('b.xml')/*/*"/>
</ResultsCollection>
 
or in XQuery
 
<ResultsCollection>{
   doc('a.xml')/*/*,
   doc('b.xml')/*/*
}</ResultsCollection>
 
and there are plenty of XSLT or XQuery processors you can invoke from your C# code.
 
Michael Kay
http://www.saxonica.com/


From: Roy Furman [mailto:RoyF@flashnetworks.com]
Sent: 31 March 2009 08:47
To: 'xml-dev@lists.xml.org'
Subject: [xml-dev] merge 2 xml file in c#

Hi

I am having trouble to merge this 2 files into 1 file using c#

Thanks for the help

 

File 1

<?xml version="1.0" encoding="utf-8"?>

  <UrlResults URL="www.google.com">

    <Result Iteration="1">

      <TimeStamp>3/26/2009 5:38:25 PM</TimeStamp>

    </Result>

    <Result Iteration="2">

      <TimeStamp>3/26/2009 5:43:17 PM</TimeStamp>

    </Result>

  </UrlResults>

 </ResultsCollection>

 

File 2

<?xml version="1.0" encoding="utf-8"?>

  <UrlResults URL="www.cnn.com">

    <Result Iteration="1">

      <TimeStamp>3/26/2009 9:19:55 PM</TimeStamp>

    </Result>

    <Result Iteration="2">

      <TimeStamp>3/26/2009 9:20:42 PM</TimeStamp>

    </Result>

    <Result Iteration="3">

      <TimeStamp>3/26/2009 9:21:19 PM</TimeStamp>

    </Result>

  </UrlResults>

  <UrlResults URL="www.google.com">

    <Result Iteration="1">

      <TimeStamp>3/27/2009 4:33:24 PM</TimeStamp>

    </Result>

  </UrlResults>

</ResultsCollection>

 

Result file should look

<?xml version="1.0" encoding="utf-8"?>

  <UrlResults URL="www.google.com">

    <Result Iteration="1">

      <TimeStamp>3/26/2009 5:38:25 PM</TimeStamp>

    </Result>

    <Result Iteration="2">

      <TimeStamp>3/26/2009 5:43:17 PM</TimeStamp>

    </Result>

            <Result Iteration="1">

      <TimeStamp>3/27/2009 4:33:24 PM</TimeStamp>

    </Result>

  </UrlResults>

  <UrlResults URL="www.cnn.com">

    <Result Iteration="1">

      <TimeStamp>3/26/2009 9:19:55 PM</TimeStamp>

    </Result>

    <Result Iteration="2">

      <TimeStamp>3/26/2009 9:20:42 PM</TimeStamp>

    </Result>

    <Result Iteration="3">

      <TimeStamp>3/26/2009 9:21:19 PM</TimeStamp>

    </Result>

  </UrlResults>

 </ResultsCollection>

 

 

 

 



This mail was sent via Mail-SeCure System.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS