【 解 説 】
XSLTを使用してXMLをHTMLに変換するには、XslCompiledTransformクラスのTransformメソッドを使用します。
この例では、XMLを”test.xml”ファイルから読み込んで、XSLファイル”test.xsl”で処理をし、”test.html”ファイルに出力します。
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
を宣言するのを忘れないようにしましょう。
【 例 文 】
1 2 3 4 5 6 7 8 |
XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("test.xsl"); XPathDocument xpathDocument = new XPathDocument("test.xml"); XmlTextWriter writer = new XmlTextWriter("test.html", System.Text.Encoding.UTF8); xslt.Transform(xpathDocument, writer); |
■お薦め参考関連資料
Microsoft、Visual Studio、Visual Basic、Visual C#、Windows Vista、Windows Server、SQL Server、Visual C++、Visual Web Developerは、米国 Microsoft Corporationの米国及びその他の国における登録商標または商標です。