Transforming XML with XSL to String

K

Krista Lemieux

Hello,

I am trying to transform XML with XSL to a string
in .NET. Currently I am using XSLTransform class, but all
the Transform() methods write to a file. How can I
Transform it straight to a string without writing to a
file and then reading back from the file (not to lose out
on performance).

Thank you for your help in advance.

Merci,
Krista Lemieux
 
S

Steve Flitcroft

Try something like this, the StringWriter is passed into the transform method and returns the transformed xml as a string

Dim xslt As XslTransform

Dim writer As New System.IO.StringWriter

Dim rdr As New IO.StringReader(xml)

Dim xmlDoc As New xml.XPath.XPathDocument(rdr)

xslt.Load(YourXSLTFile)

xslt.Transform(xmlDoc.CreateNavigator, xslArg, writer, Nothing)

Return writer.ToString
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top