xsharp.eu • C# and .NET to X# question
Page 1 of 1

C# and .NET to X# question

Posted: Fri Jan 09, 2026 10:02 am
by Jan@share.be
I want to use the XSL transform possibilities from .net. to translate a XML file to HTML

I did find an bit of code that should do this, but I have trouble translating it to X#.
So, if one of the guru's can help me out


The code I found is:


var xslt = new XslCompiledTransform();
xslt.Load(xsltPath); // gebruik Peppol stylesheet of je eigen
using var sw = new StringWriter(new StringBuilder());
using var xr = XmlReader.Create(ublXmlPath);
xslt.Transform(xr, null, sw);
string html = sw.ToString();


I got this far :
LOCAL xslt AS XSLCompiledTransForm
LOCAL sw AS StringWriter
LOCAL sb AS stringbuilder
LOCAL xr AS XMLReader
LOCAL xmlfile,lhtml,tofile AS STRING

xmlfile := 'c:\someXML.XML'
xslt := XSLCompiledTransform{}
xslt:load(ppglobals:xslt)
sb := Stringbuilder{}
sw := StringWriter{sb}
xr := XMLreader.create(xmlfile)
// xr:create(xmlfile)
xslt:transform(xr,NULL,sw)

lhtml := sw:ToString()
tofile := 'c:\SomeHTML.html'
File.WriteAlltext(tofile, lhtml)

But the code crashes on the xslt:transform call.
So, I think I got something wrong

I would like some help.

Or, if someone can give me an alternative way to get XML files converted to some readable form.

thanks

Re: C# and .NET to X# question

Posted: Sun Jan 11, 2026 11:25 pm
by Chris
Hi Jan,

Sorry for the late response, been offline for a few days.What is the exact error message/exception you are getting? The X# from c# code translation looks good to me, so it's probably a logic error in the code, or a wrong file etc. Hope you did not use ChatGPT to get the original c# code :)