Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Embed GIF Image in XML C# sample code showing how to embed a GIF image (or any binary content) in an XML document. // Add a GIF image to the Chilkat company record.
private void AddGif_Click(object sender, System.EventArgs e)
{
Chilkat.Xml xml = new Chilkat.Xml();
xml.LoadXmlFile("companies.xml");
// Quickly locate the Chilkat record.
// This updates the internal reference to point
// to the record that was found.
bool zipFlag = false;
bool aesEncryptFlag = false;
string password = ""; // Not used because aesEncryptFlag is false.
if (xml.SearchForContent2(null,"name","Chilkat*"))
{
// Move up to the record level.
xml.GetParent2();
Chilkat.Xml gifNode = xml.NewChild("gif_image","");
// The data can be optionally Zip compressed and/or AES encrypted.
gifNode.SetBinaryContentFromFile("dude.gif",zipFlag,aesEncryptFlag,password);
}
// Save the XML with the embedded GIF.
xml.GetRoot2();
xml.SaveXml("embeddedGif.xml");
// This code extracts the GIF image from the XML
Chilkat.Xml xml2 = new Chilkat.Xml();
xml2.LoadXmlFile("embeddedGif.xml");
xml2.SearchForTag2(null,"gif_image");
xml2.SaveBinaryContent("dude2.gif",zipFlag,aesEncryptFlag,password);
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.