Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870

    Convertire file XML in file TXT

    Ciao a tutti.
    Ho bisogno del vs aiuto.

    Utilizzo questo codice per trasformare un file XML in formato TXT.
    Il codice non dà errori, ma il file generato come testme.txt è sempre vuoto (0 kb).

    Cosa sbaglio?
    Grazie

    codice:
    <% 
    
    '----------
      Dim xmlSource
      Dim xmlXForm
      Dim strErr
      Dim strResult
       
      Dim fso , file
      Dim strPath
      Const ForReading = 1
      Const ForWriting = 2
      Const ForAppending = 8
     
      Set xmlSource = CreateObject("MSXML2.DOMDocument.4.0")
      Set xmlXForm = CreateObject("MSXML2.DOMDocument.4.0")
     
      xmlSource.validateOnParse = True
      xmlXForm.validateOnParse = True
      xmlSource.async = False
      xmlXForm.async = False
     
      xmlSource.Load Server.Mappath("\xml\titty.xml")
      If Err.Number <> 0 Then
          strErr = Err.Description & vbCrLf
          strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText
          Response.write strErr & "
    "
      End If
     
      xmlXForm.Load Server.Mappath("\xml\testme.xsl")
      If Err.Number <> 0 Then
          strErr = Err.Description & vbCrLf
          strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText
          Response.write strErr & "
    "
      End If
       
      strResult = xmlSource.transformNode(xmlXForm)
      If Err.Number <> 0 Then
          strErr = Err.Description & vbCrLf
          strErr = strErr & xmlSource.parseError.reason & " line: " & xmlSource.parseError.Line & " col: " & xmlSource.parseError.linepos & " text: " & xmlSource.parseError.srcText
          Response.write strErr & "
    "
      End If
     
      Set fso = CreateObject("Scripting.FileSystemObject")
      strPath = Server.Mappath("\xml\testme.txt")
    
      Set file = fso.opentextfile(strPath, ForWriting, True)
    
      file.write strResult
    
      file.Close
     
      Set file = Nothing
      Set fso = Nothing
      Set xmlSource = Nothing
      Set xmlXForm = Nothing
    '----------
    
    %>

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Mi sembra ci sia la gestione degli errori, prova a toglierla oppure a bloccare l'operazione in punti diversi per vedere quello che sta combinando...

    Roby

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.