XSLT transformation in memory using C#

前端 未结 1 1385
谎友^
谎友^ 2021-01-14 07:20

Good afternoon all,

I dont know why this is proving so difficult but I must be having one of those days!

I am trying to perform and XslCompiledTransform on

相关标签:
1条回答
  • 2021-01-14 07:59
    transformedDoc.Load(reader.ReadToEnd());
    

    Load reads from a path; you probably want transformedDoc.LoadXml(...). But in all honesty, you could just write the whole thing to a StringWriter - more direct:

    string output;
    using(var writer = new StringWriter())
    {
        processor.Transform(xdoc.CreateNavigator(), null, writer);
        output = writer.ToString();
    }
    

    Plus it will work for non-xml outputs (xslt is not obliged to output xml).

    0 讨论(0)
提交回复
热议问题