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.