Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: XML transformation

Tags:

html

c#

.net

xml

xslt

I have an XML-file with known structure, but I can't change anything on it. The task is to show data from this XML in browser (C# WebBrowser control) perhaps as html using some style sheet.

The question is how I could apply transform on existing XML without inserting anything like

 <?xml-stylesheet type="text/xsl" href="my-style.xsl"?>

I'm thinking of copy an XML somewhere, then add this xml-stylesheet and then show it in browser. But maybe I can dynamically apply style-sheet somehow?

Maybe it's possible to hold an XML in memory, apply style-sheet, and load in-memory xml to WebBrowser control?

I'm just wondering what is the best way for doing this...

like image 775
Ksice Avatar asked Jul 25 '26 14:07

Ksice


1 Answers

Sure, you can! Look at XslCompiledTransform class. So you can transform your XML in memory, then load transformed document.

like image 111
Kirill Polishchuk Avatar answered Jul 27 '26 04:07

Kirill Polishchuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!