C # xslt conversion dataset | xml

Source: Internet
Author: User
Tags xsl xslt

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 effectpath)
{

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

Extends compiledtransform xsl = new extends compiledtransform ();
Xsl. Load (effectpath );
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 effectpath)
{

XmlDataDocument xmlDoc = new XmlDataDocument (ds );
Extends compiledtransform xsl = new extends compiledtransform ();
Xsl. Load (effectpath );
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.