473,804 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

combine a few xml files

How can I build a big XML file by appending a few smaller
xml files in C#?

Below is what I've been trying:
/* FileString.xml is the path and name string of the big
xml file*/
XmlTextWriter writer = new XmlTextWriter (FileString,
System.Text.Enc oding.UTF8);
writer.WriteSta rtDocument();
writer.WriteSta rtElement("Fund XML");
/*p_FundOperatio nFileName is the string name of a smaller
xml file saved under d:\\xml\\FundOp erationXML directory */
string Text = AppendXMLFile
(p_FundOperatio nFileName, "d:\\xml\\FundO perationXML");
writer.WriteStr ing(Text);
writer.WriteEnd Element();
writer.Flush();
writer.Close();

in function AppendXMLFile:
string strfile = path +"\\"+filena me;
string s = "?>";
try
{
StreamReader sr = new StreamReader(st rfile);
String line;
/*while loop removes <?xml version="1.0" encoding="utf-8" ?
from the xml file and return the rest as string append

to the big xml file*/
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(s) ;
sr.Close();
return line.Substring( idx+2);
}
}
catch (Exception e)
{
Console.WriteLi ne(e.Message);
}

The big XML constructed this way is not "well formed" if
open it in xmlspy and xslt couldn't retrieve info from it
if it's loaded as xslt source xml file.

Please help and thanks in advance.

Nov 15 '05 #1
4 2216
Do all of the documents have the same schema? If so, you can create a
Dataset and use its ReadXml method. Do it for all three tables. If they
all have the same structure, they should all load. Then use WriteXML to
your given path.

HTH,

Bill
"PZWU" <an*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
How can I build a big XML file by appending a few smaller
xml files in C#?

Below is what I've been trying:
/* FileString.xml is the path and name string of the big
xml file*/
XmlTextWriter writer = new XmlTextWriter (FileString,
System.Text.Enc oding.UTF8);
writer.WriteSta rtDocument();
writer.WriteSta rtElement("Fund XML");
/*p_FundOperatio nFileName is the string name of a smaller
xml file saved under d:\\xml\\FundOp erationXML directory */
string Text = AppendXMLFile
(p_FundOperatio nFileName, "d:\\xml\\FundO perationXML");
writer.WriteStr ing(Text);
writer.WriteEnd Element();
writer.Flush();
writer.Close();

in function AppendXMLFile:
string strfile = path +"\\"+filena me;
string s = "?>";
try
{
StreamReader sr = new StreamReader(st rfile);
String line;
/*while loop removes <?xml version="1.0" encoding="utf-8" ?
from the xml file and return the rest as string append

to the big xml file*/
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(s) ;
sr.Close();
return line.Substring( idx+2);
}
}
catch (Exception e)
{
Console.WriteLi ne(e.Message);
}

The big XML constructed this way is not "well formed" if
open it in xmlspy and xslt couldn't retrieve info from it
if it's loaded as xslt source xml file.

Please help and thanks in advance.

Nov 15 '05 #2
Thanks Bill!
The six files combine to form a big file containing full
information about a specific mutual fund. Each smaller
file has different content therefore different schema.
Peter
-----Original Message-----
Do all of the documents have the same schema? If so, you can create aDataset and use its ReadXml method. Do it for all three tables. If theyall have the same structure, they should all load. Then use WriteXML toyour given path.

HTH,

Bill
"PZWU" <an*******@disc ussions.microso ft.com> wrote in messagenews:05******* *************** ******@phx.gbl. ..
How can I build a big XML file by appending a few smaller
xml files in C#?

Below is what I've been trying:
/* FileString.xml is the path and name string of the big
xml file*/
XmlTextWriter writer = new XmlTextWriter (FileString,
System.Text.Enc oding.UTF8);
writer.WriteSta rtDocument();
writer.WriteSta rtElement("Fund XML");
/*p_FundOperatio nFileName is the string name of a smaller xml file saved under d:\\xml\\FundOp erationXML directory */ string Text = AppendXMLFile
(p_FundOperatio nFileName, "d:\\xml\\FundO perationXML");
writer.WriteStr ing(Text);
writer.WriteEnd Element();
writer.Flush();
writer.Close();

in function AppendXMLFile:
string strfile = path +"\\"+filena me;
string s = "?>";
try
{
StreamReader sr = new StreamReader(st rfile);
String line;
/*while loop removes <?xml version="1.0" encoding="utf- 8" ?
> from the xml file and return the rest as string append

to the big xml file*/
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(s) ;
sr.Close();
return line.Substring( idx+2);
}
}
catch (Exception e)
{
Console.WriteLi ne(e.Message);
}

The big XML constructed this way is not "well formed" if
open it in xmlspy and xslt couldn't retrieve info from

it if it's loaded as xslt source xml file.

Please help and thanks in advance.

.

Nov 15 '05 #3
If they have a common column, then check out DataRelations. If you use
these, then they'll be included as well.
"pzwu" <an*******@disc ussions.microso ft.com> wrote in message
news:06******** *************** *****@phx.gbl.. .
Thanks Bill!
The six files combine to form a big file containing full
information about a specific mutual fund. Each smaller
file has different content therefore different schema.
Peter
-----Original Message-----
Do all of the documents have the same schema? If so, you

can create a
Dataset and use its ReadXml method. Do it for all three

tables. If they
all have the same structure, they should all load. Then

use WriteXML to
your given path.

HTH,

Bill
"PZWU" <an*******@disc ussions.microso ft.com> wrote in

message
news:05******* *************** ******@phx.gbl. ..
How can I build a big XML file by appending a few smaller xml files in C#?

Below is what I've been trying:
/* FileString.xml is the path and name string of the big
xml file*/
XmlTextWriter writer = new XmlTextWriter (FileString,
System.Text.Enc oding.UTF8);
writer.WriteSta rtDocument();
writer.WriteSta rtElement("Fund XML");
/*p_FundOperatio nFileName is the string name of a smaller xml file saved under d:\\xml\\FundOp erationXML directory */ string Text = AppendXMLFile
(p_FundOperatio nFileName, "d:\\xml\\FundO perationXML");
writer.WriteStr ing(Text);
writer.WriteEnd Element();
writer.Flush();
writer.Close();

in function AppendXMLFile:
string strfile = path +"\\"+filena me;
string s = "?>";
try
{
StreamReader sr = new StreamReader(st rfile);
String line;
/*while loop removes <?xml version="1.0" encoding="utf- 8" ? > from the xml file and return the rest as string append
to the big xml file*/
while ((line = sr.ReadLine()) != null)
{
int idx = line.IndexOf(s) ;
sr.Close();
return line.Substring( idx+2);
}
}
catch (Exception e)
{
Console.WriteLi ne(e.Message);
}

The big XML constructed this way is not "well formed" if
open it in xmlspy and xslt couldn't retrieve info from it if it's loaded as xslt source xml file.

Please help and thanks in advance.

.

Nov 15 '05 #4
Bill,
There are no common columns between files. What I'm trying
to do is just creating a xml file with the following form:
<?xml version="1.0" encoding="utf-8?>
<fundxml>
<content of file1 without the xml header>
<content of file2 without the xml header>
<content of file3 without the xml header>
<content of file4 without the xml header>
<content of file5 without the xml header>
<content of file6 without the xml header>
</fundxml>
Here "xml header" refers to <?xml version="1.0"
encoding="utf-8?>
Thanks for your help.
Peter
-----Original Message-----
If they have a common column, then check out DataRelations. If you usethese, then they'll be included as well.
"pzwu" <an*******@disc ussions.microso ft.com> wrote in messagenews:06******* *************** ******@phx.gbl. ..
Thanks Bill!
The six files combine to form a big file containing full
information about a specific mutual fund. Each smaller
file has different content therefore different schema.
Peter
>-----Original Message-----
>Do all of the documents have the same schema? If so, you
can create a
>Dataset and use its ReadXml method. Do it for all
three tables. If they
>all have the same structure, they should all load.
Then use WriteXML to
>your given path.
>
>HTH,
>
>Bill
>"PZWU" <an*******@disc ussions.microso ft.com> wrote in

message
>news:05******* *************** ******@phx.gbl. ..
>> How can I build a big XML file by appending a few

smaller
>> xml files in C#?
>>
>> Below is what I've been trying:
>> /* FileString.xml is the path and name string of the
big >> xml file*/
>> XmlTextWriter writer = new XmlTextWriter (FileString,
>> System.Text.Enc oding.UTF8);
>> writer.WriteSta rtDocument();
>> writer.WriteSta rtElement("Fund XML");
>> /*p_FundOperatio nFileName is the string name of a

smaller
>> xml file saved under d:\\xml\\FundOp erationXML

directory */
>> string Text = AppendXMLFile
>> (p_FundOperatio nFileName, "d:\\xml\\FundO perationXML"); >> writer.WriteStr ing(Text);
>> writer.WriteEnd Element();
>> writer.Flush();
>> writer.Close();
>>
>> in function AppendXMLFile:
>> string strfile = path +"\\"+filena me;
>> string s = "?>";
>> try
>> {
>> StreamReader sr = new StreamReader(st rfile);
>> String line;
>> /*while loop removes > >> > from the xml file and return the rest as string append >> to the big xml file*/
>> while ((line = sr.ReadLine()) != null)
>> {
>> int idx = line.IndexOf(s) ;
>> sr.Close();
>> return line.Substring( idx+2);
>> }
>> }
>> catch (Exception e)
>> {
>> Console.WriteLi ne(e.Message);
>> }
>>
>> The big XML constructed this way is not "well formed" if >> open it in xmlspy and xslt couldn't retrieve info

from it
>> if it's loaded as xslt source xml file.
>>
>> Please help and thanks in advance.
>>
>>
>>
>
>
>.
>

.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6536
by: Knighterrant | last post by:
How to combine multiple xml files into a single one, or split an xml file into multiple files using xslt?
6
8993
by: :) | last post by:
How to combine serveral large .txt files in C# without using MS command line. Thanks!!
0
1630
by: amy | last post by:
Hi, all: > i am a new end user of access, now I have many excel files need to > import to One table in access (combine all excel files into one table > in excel). In excel files, some columns will have both # and text in > the same column. The coloumn names in each excel file are mostly same > but still a lot of different names(items). I was told to set up import > specification, but how? i am not a programer or not access > professional,...
1
5318
by: Sergio | last post by:
Hello everybody. Somebody has given me nine files with some data for the years 1997, 1998, ... , 2005. They are 9 different mdb files. Each one has many tables, forms, and other things. But all of them have a table called EAL, with fields like year (this year contains, for all the registers, the year corresponding the one indicated by the file name), name, surname, country and much more fields.
4
3726
by: kumar_ps | last post by:
I am using vb6.0 here i am using "tif" files my program is i am keeping some tif files in a folder. when i run the program that all the tif files combine one file. i mean suppose we take 4tif files in that folder when i run the program automatically 4tif files combine 1 file i mean page by page
5
12921
by: Rodjk #613 | last post by:
Hello, I am working with a database that is in use in several locations. The structure of the databases are identical, but the data is different. I am tasked with combining the data into one large database. (It is SQL 2000) I have .bak files for each location. Is there any way to restore a backup into a database, combining the data?
7
5187
by: SNN | last post by:
Hi, I have 4 files that I would like to combine side by side and the seperater is tab in these four files. I also would like to have the output file to be tab delimited. All 4 files have the same legnth. I wrote the following script where I get an error message at the "k" loop. It does not understand "$#L$s" . what I would like is to print @L1 followed by @L2, @L3, and @L4 side by side with tab as a deliminator. #!/usr/bin/perl _w
3
1933
by: johnqsmith | last post by:
Problem background: gcc v 4.1 2 .cpp files, 2 .h files Files: main.cpp a.cpp a.h b.h
6
1805
by: PDSTAR | last post by:
Hello, Any help would be much appreciated. I have a directory of ~2000 tab delimited .txt files. I would like to combine all these files (append to the last blank row) into a master file. The one catch is, I need the filename from which the data is drawn to be the first item in every row of the master file. For example: I don't know how to insert tabs into this message, so I'll insert "|" where a tab would be. File 1: Name = "ABC.txt"...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.