Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) XMP API Helps Build the XML

The Chilkat XMP API is helpful in making it easier to build the XML that comprises XMP. If an XMP API feature does not exist to create the desired XML structure, then the Chilkat XML API can be used. The important thing to notice is that all XMP methods that modify XML pass the XML to be modified in the 1st argument. Thus, the XMP methods are really just helper methods to do common tasks in creating/editing the XML.

This example shows how to create a bag with a more complicated structure -- something that is not automatically provided by the XMP API, but can easily be done using the XML API.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoXmp
    Variant vXml
    Handle hoXml
    Boolean iSuccess
    Variant vSa
    Handle hoSa
    Variant vX
    Handle hoX
    String sTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatXmp)) To hoXmp
    If (Not(IsComObjectCreated(hoXmp))) Begin
        Send CreateComObject of hoXmp
    End

    // The first step is to create a new XMP document, which is nothing
    // more than XML.  The NewXmp method returns an XML document with
    // the standard XMP boilerplate.  
    Get ComNewXmp Of hoXmp To vXml
    If (IsComObject(vXml)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoXml
        Set pvComObject Of hoXml To vXml
    End

    // Add some properties...
    Get ComAddSimpleStr Of hoXmp vXml "Iptc4xmpCore:Chilkat" "Blah blah" To iSuccess

    // Now create a Bag.
    Get Create (RefClass(cComCkStringArray)) To hoSa
    If (Not(IsComObjectCreated(hoSa))) Begin
        Send CreateComObject of hoSa
    End
    Get ComAppend Of hoSa "value_1" To iSuccess
    Get ComAppend Of hoSa "value_2" To iSuccess
    // ...

    // Notice the XML object is passed in the 1st argument.
    // The XMP method is really just a higher-level means to create XML
    // commonly needed for XMP.
    Get pvComObject of hoSa to vSa
    Get ComAddArray Of hoXmp vXml "bag" "Iptc4xmpExt:LocationCreated" vSa To iSuccess

    // Let's examine the XML..
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1

    // the bag looks like this:

    //     <Iptc4xmpExt:LocationCreated>
    //         <rdf:Bag>
    //             <rdf:li>value_1</rdf:li>
    //             <rdf:li>value_2</rdf:li>
    //         </rdf:Bag>
    //     </Iptc4xmpExt:LocationCreated>

    // Let's say we really want this:

    //  <Iptc4xmpExt:LocationCreated>
    //    <rdf:Bag>
    //     <rdf:li rdf:parseType='Resource'>
    //      <Iptc4xmpExt:City>Ville création photo</Iptc4xmpExt:City>
    //      <Iptc4xmpExt:CountryName>Nom diu pays de la photo</Iptc4xmpExt:CountryName>
    //      <Iptc4xmpExt:ProvinceState>Département; Photo</Iptc4xmpExt:ProvinceState>
    //      <Iptc4xmpExt:Sublocation>Lieu création photo</Iptc4xmpExt:Sublocation>
    //     </rdf:li>
    //    </rdf:Bag>
    //   </Iptc4xmpExt:LocationCreated>

    // No problem...  Let's just fix it.

    Get ComSearchForTag Of hoXml vXml "Iptc4xmpExt:LocationCreated" To vX
    If (IsComObject(vX)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoX
        Set pvComObject Of hoX To vX
    End

    // Assume it was found..
    // Move to the rdf:Bag node
    Get ComFirstChild2 Of x To iSuccess

    // Discard the existing <rdf:il> values..
    Send ComRemoveAllChildren To x

    // Build the new XML in its place..
    Send ComNewChild2 To x "rdf:li" ""
    Get ComAddAttribute Of x "rdf:parseType" "Resource" To iSuccess

    // Move to the "rdf:li" node.
    Get ComFirstChild2 Of x To iSuccess
    Send ComNewChild2 To x "Iptc4xmpExt:City" "Ville création photo"
    Send ComNewChild2 To x "Iptc4xmpExt:CountryName" "Nom diu pays de la photo"
    Send ComNewChild2 To x "Iptc4xmpExt:ProvinceState" "Département; Photo"
    Send ComNewChild2 To x "Iptc4xmpExt:Sublocation" "Lieu création photo"

    // Let's create another bag item..
    // Move back up to the "rdf:Bag" node.
    Get ComGetParent2 Of x To iSuccess

    Send ComNewChild2 To x "rdf:li" ""
    Get ComAddAttribute Of x "rdf:parseType" "Resource" To iSuccess

    // Move to the newly added "rdf:li" node, which is the 2nd child (index = 1)
    Get ComGetChild2 Of x 1 To iSuccess
    Send ComNewChild2 To x "Iptc4xmpExt:City" "2 Ville création photo"
    Send ComNewChild2 To x "Iptc4xmpExt:CountryName" "2 Nom diu pays de la photo"
    Send ComNewChild2 To x "Iptc4xmpExt:ProvinceState" "2 Département; Photo"
    Send ComNewChild2 To x "Iptc4xmpExt:Sublocation" "2 Lieu création photo"

    Send Destroy of x

    // Let's examine the XML now...
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1

    Send Destroy of hoXml


End_Procedure

 

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