469,899 Members | 1,460 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,899 developers. It's quick & easy.

XML to HTML using XSLT

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
2 1529
"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
"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.

Similar topics

2 posts views Thread by Sylvia | last post: by
5 posts views Thread by Fred | last post: by
2 posts views Thread by Allan Bredahl | last post: by
3 posts views Thread by Andy Dingley | last post: by
12 posts views Thread by Chris | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.