Path: csiph.com!aioe.org!.POSTED!not-for-mail From: "Sauro" Newsgroups: it.comp.lang.visual-basic Subject: Re: File XML con VB6 Date: Wed, 14 Mar 2018 09:29:36 +0100 Organization: Aioe.org NNTP Server Lines: 56 Message-ID: References: NNTP-Posting-Host: cJiBue5zpFmt6gTV0BRp+A.user.gioia.aioe.org X-Complaints-To: abuse@aioe.org X-Priority: 3 X-Notice: Filtered by postfilter v. 0.8.3 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-MSMail-Priority: Normal Xref: csiph.com it.comp.lang.visual-basic:19322 > Se tu la potessi condividere qua....grazie :) Ecco qua: Public Sub FormatDocToFile(ByVal doc As MSXML2.DOMDocument, _ ByVal FileName As String) 'Nel progetto serve il riferimento a: 'Microsoft XML, version 2.0 ' 'Reformats the DOMDocument "Doc" into an ADODB.Stream 'and writes it to the specified file. ' 'Note the UTF-8 output never gets a BOM. If we want one we 'have to write it here explicitly after opening the Stream. Dim rdrDom As MSXML2.SAXXMLReader Dim stmFormatted As ADODB.Stream Dim wtrFormatted As MSXML2.MXXMLWriter Set stmFormatted = New ADODB.Stream With stmFormatted .Open .Type = adTypeBinary Set wtrFormatted = New MSXML2.MXXMLWriter With wtrFormatted .omitXMLDeclaration = False .standalone = True .byteOrderMark = False 'If not set (even to False) then '.encoding is ignored. .encoding = "utf-8" 'Even if .byteOrderMark = True 'UTF-8 never gets a BOM. .Indent = True .Output = stmFormatted Set rdrDom = New MSXML2.SAXXMLReader With rdrDom Set .contentHandler = wtrFormatted Set .dtdHandler = wtrFormatted Set .errorHandler = wtrFormatted .putProperty "http://xml.org/sax/properties/lexical-handler", _ wtrFormatted .putProperty "http://xml.org/sax/properties/declaration-handler", _ wtrFormatted .parse doc End With End With .SaveToFile FileName .Close End With End Sub Ciao Greg Sauro