質問
申請をしたいのです、XSLTスタイルシートをXMLドキュメントをC#に書き出力をファイルです。
解決
発見可能な回答はこちら http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63
からの記事:
XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ;
XslTransform myXslTrans = new XslTransform() ;
myXslTrans.Load(myStyleSheet);
XmlTextWriter myWriter = new XmlTextWriter("result.html",null) ;
myXslTrans.Transform(myXPathDoc,null,myWriter) ;
編集:
私のトラスティコンパイラは、 XslTransform
は旧式のもの:使用 XslCompiledTransform
代わり:
XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ;
XslCompiledTransform myXslTrans = new XslCompiledTransform();
myXslTrans.Load(myStyleSheet);
XmlTextWriter myWriter = new XmlTextWriter("result.html",null);
myXslTrans.Transform(myXPathDoc,null,myWriter);
他のヒント
に基づく大仁の優れた答えは、このコードを大幅に短縮できます。を活用し XslCompiledTransform.変換過負荷:
var myXslTrans = new XslCompiledTransform();
myXslTrans.Load("stylesheet.xsl");
myXslTrans.Transform("source.xml", "result.html");
(ポージング用としての答えが、 code block
支援コメントをしにくくなるからです。)
にVB.NETすな変数:
With New XslCompiledTransform()
.Load("stylesheet.xsl")
.Transform("source.xml", "result.html")
End With
こちらはチュートリアル方法についXSL Transformationsクライアントまで、フルのC#にMSDN:
http://support.microsoft.com/kb/307322/en-us/
ここでは書き方のファイル:
http://support.microsoft.com/kb/816149/en-us
だとして注おすすめの検証にもここは別のチュートリアル(DTD XDR、XSD(=スキーマ)):
http://support.microsoft.com/kb/307379/en-us/
加えこれだけの提供があります。
所属していません StackOverflow