Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(DataFlex) Demonstrate the XML FindNextRecord Method

Imagine we have an XML file as follows:

<CompleteMultipartUpload>
  <Part>
    <PartNumber>1</PartNumber>
    <ETag>abc</ETag>
  </Part>
  <Part>
    <PartNumber>2</PartNumber>
    <ETag>def</ETag>
  </Part>
  <Part>
    <PartNumber>3</PartNumber>
    <ETag>ghi</ETag>
  </Part>
</CompleteMultipartUpload>
We want to find the record where PartNumber = 2. To do so, we simply position ourselves at the first "Part" tag, and then call FindNextRecord. (See below..)

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoXml
    Variant vFoundRec
    Handle hoFoundRec
    String sTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End

    Get ComLoadXmlFile Of hoXml "qa_data/xml/multipartUpload.xml" To iSuccess

    //  Position ourselves at the 1st record.
    Get ComGetChild2 Of hoXml 0 To iSuccess

    Get ComFindNextRecord Of hoXml "PartNumber" "2" To vFoundRec
    If (IsComObject(vFoundRec)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoFoundRec
        Set pvComObject Of hoFoundRec To vFoundRec
    End
    Get ComLastMethodSuccess Of hoXml To bTemp1
    If (bTemp1 = True) Begin
        Showln "Found the record where PartNumber = 2."
        Get ComGetXml Of hoFoundRec To sTemp1
        Showln sTemp1

        //  Let's examine the ETag for this record...
        Get ComGetChildContent Of hoFoundRec "ETag" To sTemp1
        Showln "ETag for PartNumber 2 = " sTemp1
        Send Destroy of hoFoundRec
    End
    Else Begin
        Showln "No record exists where PartNumber = 2."
    End

    //  What if we want to find the record where ETag = "abc"?
    Get ComFindNextRecord Of hoXml "ETag" "abc" To vFoundRec
    If (IsComObject(vFoundRec)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoFoundRec
        Set pvComObject Of hoFoundRec To vFoundRec
    End
    Get ComLastMethodSuccess Of hoXml To bTemp1
    If (bTemp1 = True) Begin
        Showln "Found the record where ETag = abc"
        Get ComGetXml Of hoFoundRec To sTemp1
        Showln sTemp1

        //  Let's examine the PartNumber for this record...
        Get ComGetChildContent Of hoFoundRec "PartNumber" To sTemp1
        Showln "Part number for Etag(abc) = " sTemp1
        Send Destroy of hoFoundRec
    End
    Else Begin
        Showln "No record exists where ETag = abc."
    End

    //  Go back to the XML root..
    Send ComGetRoot2 To hoXml


End_Procedure

 

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