hello,
I am trying to do an xsl tranformation from an XML file into
another xml file. I want the output file to be in MemoryStream so that my
dataset can direclty read xml using
dataset.ReadXml (memoryStream).
But at the time of reading it gives following exception
System.Xml.XmlE xception: The root element is missing.
But if i write into a file and then read dataset from that then it works fine.
PLEASE HELP ME
The whole code is attached below
Thanks,
The whole code is
using System;
using System.Xml.Xsl;
using System.Xml.XPat h;
using System.Xml;
using System.IO;
using System.Data;
namespace XslMapper
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
//Create a new XslTransform object.
XslTransform xslt = new XslTransform();
//Load the stylesheet.
xslt.Load("Abc. xsl");
//Create a new XPathDocument and load the XML data to be
transformed.
XPathDocument mydata = new XPathDocument(" XYZ.xml");
MemoryStream mstream = new MemoryStream();
//Create an XmlTextWriter which outputs to the console.
StreamWriter writer = new StreamWriter(ms tream);
xslt.Transform( mydata,null,wri ter,null);
DataSet ds = new DataSet();
ds.ReadXml(mstr eam);
foreach (DataTable dt in ds.Tables)
foreach ( DataRow dr in dt.Rows)
foreach (DataColumn dc in dt.Columns)
Console.WriteLi ne(dr[dc].ToString());
re.Close();
}
}
}