Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:21+00:00 2026-06-13T22:50:21+00:00

I am using XSLT in conjunction with C# to transform my xml document into

  • 0

I am using XSLT in conjunction with C# to transform my xml document into HTML. I need the DOCTYPE to be in the HTML document. But somehow I can’t seem to get it to appear. Please help…

My xsl includes the following.

<?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <xsl:output method="xml" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes"/>

My C# code looks like this :

try
{
    XPathDocument myXPathDoc = new XPathDocument(myPath);

    XslTransform myXslTrans = new XslTransform();

    myXslTrans.Load(ConfigurationManager.AppSettings["XsltFilePath"] == null ? 
        "MyTransform.xsl" : 
        ConfigurationManager.AppSettings["XsltFilePath"]);

    String htmlFile = Path.Combine(myFolder, myName, "index.html");

    XmlTextWriter myWriter = new XmlTextWriter(htmlFile, null);

    myXslTrans.Transform(myXPathDoc, null, myWriter);

    myWriter.Close();
}
catch (Exception e)
{
    System.Console.WriteLine(e.Message + "\n" + e.StackTrace);
}

Any ideas what I am doing wrong? I am using .NET 4.0. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:50:22+00:00Added an answer on June 13, 2026 at 10:50 pm

    Well don’t write to an XmlTextWriter, simply use an overload that writes to a file e.g.

    XslCompiledTransform proc = new XslCompiledTransform();
    proc.Load(ConfigurationManager.AppSettings["XsltFilePath"] == null ? "MyTransform.xsl" : ConfigurationManager.AppSettings["XsltFilePath"]);
    
    String resultFileName = Path.Combine(myFolder, myName, "index.html");
    
    proc.Transform(myPath, resultFileName);
    

    I used XslCompiledTransform instead of XslTransform as the latter is deprecated since .NET 2.0.

    If you really want to use XslTransform then there is a similar Transform method http://msdn.microsoft.com/en-us/library/x6e130yd.aspx you can use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using XSLT to transform XML into HTML. In the below code, I
I am using xslt to transform an xml document to html for use in
I am using XSLT to convert a very large XML document into (X)HTML. For
I am using XSLT to transform some provisioning XML into a SOAP request. But
I'm using XSLT to transform from one format of XML into another but I
I am using XSLT to transform a XML into a html/php file. In this
I need to transform XML using xslt. Logic: Split the parent if the parent
I'm using XSLT to transform an XML document to text. The text nodes of
I am using xslt to transform an xml file to html. The .net xslt
I am using XSLT to transform XML to HTML. Currently i am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.