XSL - XML
Por MigueliTUX Oct.28, 2008, categoría VB.60, Windows
Aqui les dejo un codigo que inclui en una componente. Se trata de dos metodos que hacen lo mismo, transformar el xml con un xsl a una pagina web.
Option Explicit
****** Esta funcion transforma el archivo XML con el Archivo XSL ******
****** Retorna el string que despues en la pagina asp se dibuja con
****** request.write(string)
Public Function TransXML2String(ByVal xmlFile As String, ByVal xslFile As String) As String
Dim source As New Msxml2.DOMDocument30
Dim stylesheet As New Msxml2.DOMDocument30
Dim myErr
Dim msgReturn As String
‘ Load data.
source.async = False
source.Load (xmlFile)
If (source.parseError.errorCode <> 0) Then
Set myErr = source.parseError
msgReturn = myErr.reason
Else
‘ Load style sheet.
stylesheet.async = False
stylesheet.Load (xslFile)
If (stylesheet.parseError.errorCode <> 0) Then
Set myErr = stylesheet.parseError
msgReturn = myErr.reason
Else
‘ Do the transform.
msgReturn = source.transformNode(stylesheet)
End If
End If
TransXML2String = msgReturn
End Function
****** Esta funcion transforma el string XML con el Archivo XSL ******
****** Retorna el string que despues en la pagina asp se dibuja con
****** request.write(string)
Public Function TransStringXML2String(ByVal xmlString As String, ByVal xslFile As String) As String
Dim source As New Msxml2.DOMDocument30
Dim stylesheet As New Msxml2.DOMDocument30
Dim myErr
Dim msgReturn As String
‘ Load data.
source.async = False
source.loadXML (xmlString)
If (source.parseError.errorCode <> 0) Then
Set myErr = source.parseError
msgReturn = myErr.reason
Else
‘ Load style sheet.
stylesheet.async = False
stylesheet.Load (xslFile)
If (stylesheet.parseError.errorCode <> 0) Then
Set myErr = stylesheet.parseError
msgReturn = myErr.reason
Else
‘ Do the transform.
msgReturn = source.transformNode(stylesheet)
End If
End If
TransStringXML2String = msgReturn
End Function
April 3rd, 2010 on 1:48 pm
[...] - XML http://www.tips.cl/archives/113 #TipsCL [...]