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

  • SEARCH
  • Home
  • 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 486999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:33:37+00:00 2026-05-13T01:33:37+00:00

I have modified the title of the question after finding the answer :) :P

  • 0

I have modified the title of the question after finding the answer 🙂 😛

I am loading an XML file and an XSL file by a C# program and triggering the XSL transformation .. here is the code for it:

static void Main(string[] args)
{

    // Create the XslCompiledTransform and load the stylesheet.
    XslCompiledTransform xslt = new XslCompiledTransform();
    xslt.Load("input.xsl");    //located in Debug folder
    //Load XSL argument list
    XsltArgumentList xslArg = new XsltArgumentList();

    // Transform the file.
    using (XmlWriter w = XmlWriter.Create("output.xml"))
    {
        xslt.Transform("input.xml", xslArg, w);    //located in Debug folder
    }
}

The error is I am not able to load XML file.

The XSL file contains some C# code which is meant to calculate the difference between two DateTime strings .. well, I can transform the XML file manually using the same XSL file .. But when I try to trigger the transformation using C# code .. then it says “It can’t load XML file”

Here is my (part of) XSL code ..

<span bgcolor="#EEEEEE">

   &lt;xsl:variable name="date1" select="//date1"/&gt;
   &lt;xsl:variable name="date2" select="//date2"/&gt;

   &lt;msxsl:script language="C#" implements-prefix="cs"&gt;
   &lt;![CDATA[
         public string datediff(string date1, string date2) {

            DateTime startTime = new DateTime(Convert.ToInt32(date1.Substring(6, 4)), Convert.ToInt32(date1.Substring(0, 2)), Convert.ToInt32(date1.Substring(3, 2)), Convert.ToInt32(date1.Substring(11, 2)), Convert.ToInt32(date1.Substring(14, 2)), Convert.ToInt32(date1.Substring(17, 2)), 0);

            DateTime endTime = new DateTime(Convert.ToInt32(date2.Substring(6, 4)), Convert.ToInt32(date2.Substring(0, 2)), Convert.ToInt32(date2.Substring(3, 2)), Convert.ToInt32(date2.Substring(11, 2)), Convert.ToInt32(date2.Substring(14, 2)), Convert.ToInt32(date2.Substring(17, 2)), 0);

    return(endTime.Subtract(startTime));

         }
     ]]>
   &lt;/msxsl:script&gt;<br>
   &lt;xsl:template match="datediff"&gt;<br>
    &lt;xsl:element name="{local-name()}"&gt;<br>
      &lt;xsl:value-of select="cs:datediff($date1, $date2)" /&gt;<br>
    &lt;/xsl:element&gt;<br>
   &lt;/xsl:template&gt;<br></span>

Is that, because of script(C# code to calculate date diff..) I am getting this error?
By the way C# code runs perfectly when I use some other input XML and XSL files ..

please help me to overcome this error ..

  • 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-05-13T01:33:37+00:00Added an answer on May 13, 2026 at 1:33 am

    As Steve cooper has mentioned .. you need to enable the XSLT script .. and here is the way to do it:

    first define a new settings instance:

    var settings = new XsltSettings();
    

    then enable the script

    settings.EnableScript = true;
    

    Create the XslCompiledTransform object and load the style sheet, passing in the settings object.

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

Sidebar

Ask A Question

Stats

  • Questions 252k
  • Answers 252k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're asking too many questions in one question. One question… May 13, 2026 at 9:46 am
  • Editorial Team
    Editorial Team added an answer No, it is not possible. The inserted content has no… May 13, 2026 at 9:46 am
  • Editorial Team
    Editorial Team added an answer SQL Server isn't really timezone aware. If you store 2:36… May 13, 2026 at 9:46 am

Related Questions

I started with this question: Multiple Javascript gadgets per page . After reading up
I've recently been given the… opportunity … to completely redesign the layout of a
I'm playing around with javafx and I have modified the code of the MediaPleyer
well, the title pretty much says it all. here's a little info: i have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.