By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,493 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,493 IT Pros & Developers. It's quick & easy.

XML to HTML using XSLT

P: n/a
Hi All

I'm trying hard to find out how to transform XML to HTML using XSLT files.

I have searched all over for some examples on how to do this, but I have had
no succes with any of them.
Can sombody please direct me on how to fill in this function:
Public Function XmlToHtml(ByVal xmlString as string, ByVal xsltPath as
string) as string
'xmlString being a string containing the XML to be transformed
'xsltPath being the path to the actual XSLT file containing the
transform styles

Dim ResultHTML as string

'???????

Return ResultHTML
End Function
I have worked with XslTransform and XPath, but can't seem to work it out.
Thanks in advance

Allan Bredahl
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Allan Bredahl" <ad***@bredahl.org> wrote:
I'm trying hard to find out how to transform XML to HTML using XSLT files.
I have worked with XslTransform and XPath, but can't seem to work it out.


In my apps I use the following function, however, I'm transforming
file to file, not string to string, as my documents can get quite
sizeable. It may give you something to go on - I'd imagine there's a
version of xsltransdform.transform that accepts a string, I'm not in a
position to look at the moment.

Public Sub DoTransform(ByVal InputFile As String, ByVal OutFile As
String, ByVal StyleSheetFile As String)
Dim xslt As New Xsl.XslTransform
xslt.Load(StyleSheetFile)
xslt.Transform(InputFile, OutFile, Nothing)
End Sub

Jul 21 '05 #2

P: n/a
"Brett O'Callaghan" <br*************@hotmail.com> skrev i en meddelelse
In my apps I use the following function, however, I'm transforming
file to file, not string to string, as my documents can get quite
sizeable. It may give you something to go on - ......


Hi

Thanks for your reply.

I have now found a solution, mostly by luck I believe :) :

Private Function TransformXML(ByVal xml As String, ByVal xsltPath As
String) As String
Dim trans As New XslTransform
Dim doc As New XmlDocument
Dim html As String
Dim writer As StringWriter = New StringWriter

trans.Load(xsltPath)
doc.LoadXml(xml)
trans.Transform(doc, Nothing, writer, Nothing)
html = writer.ToString
writer.Close()
Return html
End Function 'Main

/Allan
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.