Perl Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Perl Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SMTP
Socket / SSL
Spider
SFTP
SSH Key
SSH
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

Saving and Retrieving Data in XML

Saving and retrieving data in XML.

 Chilkat Perl Module Downloads for Windows, Linux, and MAC OS X

use chilkat();


#  Create an XML file with data that will later be loaded and
#  accessed by field name:
$xml = new chilkat::CkXml();
$xml->put_Tag("emailData");

$xml->NewChild2("from",'admin@chilkatsoft.com');
$xml->NewChild2("toName","Chilkat Support");
$xml->NewChild2("toAddr",'support@chilkatsoft.com');
$xml->NewChild2("subject","This is a test");
$xml->NewChild2("body","This is an email body");

#  Save the XML:

$success = $xml->SaveXml("emailData.xml");
if ($success != 1) {
    print $xml->lastErrorText() . "\n";
    exit;
}

$xml2 = new chilkat::CkXml();

#  Load the XML file:
$success = $xml2->LoadXmlFile("emailData.xml");
if ($success != 1) {
    print $xml2->lastErrorText() . "\n";
    exit;
}

#  Access the data by name
print $xml2->getChildContent("from") . "\r\n";
print $xml2->getChildContent("toName") . "\r\n";
print $xml2->getChildContent("toAddr") . "\r\n";
print $xml2->getChildContent("subject") . "\r\n";
print $xml2->getChildContent("body") . "\r\n";
print "------" . "\r\n";

#  Let's say I want to load this into an email object:
$email = new chilkat::CkEmail();

$email->put_From($xml2->getChildContent("from"));

$toName = $xml2->getChildContent("toName");
$toAddr = $xml2->getChildContent("toAddr");
$email->AddTo($toName,$toAddr);
$email->put_Subject($xml2->getChildContent("subject"));
$email->put_Body($xml2->getChildContent("body"));

print $email->getMime() . "\r\n";


 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.