Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
XML Embed Binary FileDemonstrates how to embed a binary file in XML. Also extracts binary data from XML and saves to a file.
LOCAL loFileData LOCAL loFac LOCAL loXml LOCAL lnZipFlag LOCAL lnEncryptFlag LOCAL lcPassword LOCAL lnSuccess LOCAL lnFacSuccess * Load a binary file from disk: loFac = CreateObject('Chilkat.FileAccess') loFileData = loFac.ReadEntireFile("dude.gif") loXml = CreateObject('Chilkat.Xml') loXml.Tag = "gifData" * If set to 1, the binary data is automatically compressed * before being added to the XML. In this example, GIF data * is already a compressed file format, so we another layer * of compression doesn't really help much... lnZipFlag = 0 * The data may be automatically 128-bit AES encrypted * if this flag is set to 1. lnEncryptFlag = 0 lcPassword = "NotUsed" lnSuccess = loXml.SetBinaryContent(loFileData,lnZipFlag,lnEncryptFlag,lcPassword) * Examine the XML. (The binary content is base64-encoded) ? loXml.GetXml() * Now extract the content to a file: lnSuccess = loXml.SaveBinaryContent("out.gif",lnZipFlag,lnEncryptFlag,lcPassword) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loXml.LastErrorText) ENDIF * The original data may be saved using the FileAccess component in this way: lnFacSuccess = loFac.WriteEntireFile("original.gif", loFileData) IF (lnFacSuccess = 0) THEN =MESSAGEBOX(loFac.LastErrorText) QUIT ENDIF |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser