C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着

public string ReadFile(string path)
        {
            string tempContent = "";
            using (StreamReader sr = new StreamReader(path,System.Text.Encoding.GetEncoding("gb2312")))
            {
                tempContent = sr.ReadToEnd();
            }
            return tempContent;
        }
        private string TransfromXmlStringToHtml(string XmlString, string xsltpath)
        {

            StringReader xml = new StringReader(XmlString);
            XPathDocument xmlDoc = new XPathDocument(xml);

            XslCompiledTransform xsl = new XslCompiledTransform();
            xsl.Load(xsltpath);
            string temp = "";
            System.IO.Stream str = new System.IO.MemoryStream();
            xsl.Transform(xmlDoc, null, str);
            str.Flush();
            str.Position = 0;
            using (System.IO.StreamReader sr = new System.IO.StreamReader(str, System.Text.Encoding.GetEncoding("GB2312")))
            {
                temp = sr.ReadToEnd();
            };
            return temp;
        }

        private string TransfromXmlToHtml(DataSet ds, string xsltpath)
        {

            XmlDataDocument xmlDoc = new XmlDataDocument(ds);
            XslCompiledTransform xsl = new XslCompiledTransform();
            xsl.Load(xsltpath);
            string temp = "";
            System.IO.Stream str = new System.IO.MemoryStream();
            xsl.Transform(xmlDoc, null, str);
            str.Flush();
            str.Position = 0;
            using (System.IO.StreamReader sr = new System.IO.StreamReader(str, System.Text.Encoding.UTF8))
            {
                temp = sr.ReadToEnd();
            };
            return temp;
        }

posted on 2010-11-24 10:20  王德田  阅读(360)  评论(0编辑  收藏  举报