' ------------------------------------------------------------------------------------ ' TestXMLExport.vbs ' This script shows how to use the xmlEncode and xmlDecodePicture methods. ' ------------------------------------------------------------------------------------ Option Explicit Const ForReading = 1, ForWriting = 2 Const TemporaryFolder = 2 dim alb, pic, newPic, xmlStream, sFileName, k, outputFolder, fso, f, s, sNewFile app.ClearTrace set alb = app.GetCurrentAlbum set pic = alb.GetVisiblePicture( alb.nCurrentPicture ) app.trace "Generating xml stream for picture '" & pic.sShortFileName & "'" xmlStream = pic.xmlEncode( 0 ) sFileName = alb.ExpandMacro( pic, "%RP" ) k = InStrRev( sFileName, "." ) sFileName = left( sFileName, k ) & "xml" app.trace "Saving xml stream in '" & sFileName & "'" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile( sFileName, ForWriting, True ) f.WriteLine xmlStream f.Close ' Open the xml file in Internet Explorer app.Run sFileName, True, 1 app.trace "Reloading the xml file from disk..." Set f = fso.OpenTextFile( sFileName, ForReading ) xmlStream = f.ReadAll 'k = 0 'Do While f.AtEndOfStream <> True ' s = f.Read 'Line ' xmlStream = xmlStream & s ' ' Just display the first lines of the file ' if k < 20 then app.Trace chr(9) & s ' k = k + 1 'Loop f.Close ' Recreate the picture from the stream and save it in the temp folder Set outputFolder = fso.GetSpecialFolder( TemporaryFolder ) sNewFile = outputFolder.Path & "\" & pic.sShortFileName app.Trace "Saving picture as '" & sNewFile & "'..." set newPic = alb.xmlDecodePicture( xmlStream, outputFolder.Path ) alb.redraw set fso = Nothing app.Trace "Done !!!"