Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

 

Saving and Retrieving Data in XML

Saving and retrieving data in XML.

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

#include <CkXml.h>
#include <CkEmail.h>
#include <CkString.h>

void ChilkatSample(void)
    {

    //  Create an XML file with data that will later be loaded and
    //  accessed by field name:
    CkXml xml;
    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:
    bool success;
    success = xml.SaveXml("emailData.xml");
    if (success != true) {
        printf("%s\n",xml.lastErrorText());
        return;
    }

    CkXml xml2;

    //  Load the XML file:
    success = xml2.LoadXmlFile("emailData.xml");
    if (success != true) {
        printf("%s\n",xml2.lastErrorText());
        return;
    }

    //  Access the data by name
    printf("%s\n",xml2.getChildContent("from"));
    printf("%s\n",xml2.getChildContent("toName"));
    printf("%s\n",xml2.getChildContent("toAddr"));
    printf("%s\n",xml2.getChildContent("subject"));
    printf("%s\n",xml2.getChildContent("body"));
    printf("------\n");

    //  Let's say I want to load this into an email object:
    CkEmail email;

    email.put_From(xml2.getChildContent("from"));
    CkString toName;
    CkString toAddr;
    toName = xml2.getChildContent("toName");
    toAddr = xml2.getChildContent("toAddr");
    email.AddTo(toName,toAddr);
    email.put_Subject(xml2.getChildContent("subject"));
    email.put_Body(xml2.getChildContent("body"));

    printf("%s\n",email.getMime());


    }

Need a specific example? Send a request to support@chilkatsoft.com

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

Mail Component · .NET Mail Component · XML Parser