0

I have a xml document like below and I need to render it into HTML page. When I browse the XML from IE the HTML is rendered as expected with styling. If I load the xml document from c# code and pass to HTML page it just renders as plain text. What am I missing here?

XML

<?xml-stylesheet type='text/xsl' href='xslsheet.xsl'?>
<Document xmlns="org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
....
</Document>

C#

XDocument doc = XDocument.Load(@"C\SampleDocument.xml");
      var result = doc.ToString();

1 Answer 1

1

Loading an XML document does just that - it loads the data. It won't process a transform directive.

To do that you need to do an XSLT Transform. You can find the classes to do that on MSDN.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.