[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: merge 2 xml file in c#

  • From: Roy Furman <RoyF@f...>
  • To: 'Michael Kay' <mike@s...>, "xml-dev@l..."<xml-dev@l...>
  • Date: Tue, 31 Mar 2009 11:26:34 +0300

RE:  merge 2 xml file in c#

10x

I do not know XSLT I will try to Google it

Basically I need to take all the xml files from a specific directory and build 1 xml file

Can you help me to write the program with xslt and c#?

I used dataset before but when I used the merge function the created result was not as I wanted it

 


From: Michael Kay [mailto:mike@s...]
Sent: Tuesday, March 31, 2009 11:21 AM
To: Roy Furman; xml-dev@l...
Subject: RE: 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@f...]
Sent: 31 March 2009 08:47
To: 'xml-dev@l...'
Subject: 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.



This mail was sent via Mail-SeCure System.


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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.