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

Android™ 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

 

 

 

(Android™) Demonstrate the XML I, J, and K Properties

Demonstrates the XML I, J, and K properties. These properties can be used in paths to access the I'th, J'th, or K'th child in a path. Three indexing properties are provided to allow for triple-nested loops using this feature.

Note: This example requires Chilkat v9.5.0.64 or later.

Chilkat Android™ Downloads

Android™ Java Libraries

Android C/C++ Libraries

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //  Note: This example requires Chilkat v9.5.0.64 or later.

    CkXml xml = new CkXml();

    xml.put_Tag("tripleNested");

    int i = 0;
    int j = 0;
    int k = 0;

    CkStringBuilder sbValue = new CkStringBuilder();
    boolean bAutoCreate = true;

    while (i < 3) {
        xml.put_I(i);
        j = 0;
        while (j < 4) {
            xml.put_J(j);
            k = 0;
            while (k < 2) {
                xml.put_K(k);

                int n = i * 100 + j * 10 + k;
                sbValue.Clear();
                sbValue.AppendInt(n);

                xml.UpdateAt("a[i]|b[j]|c[k]",bAutoCreate,sbValue.getAsString());
                k = k + 1;
                }

            j = j + 1;
            }

        i = i + 1;
        }

    Log.i(TAG, xml.getXml());

    //  This is the XML
    //  See below for code showing how to parse it..

    //  	<?xml version="1.0" encoding="utf-8" ?>
    //  	<tripleNested>
    //  	    <a>
    //  	        <b>
    //  	            <c>0</c>
    //  	            <c>1</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>10</c>
    //  	            <c>11</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>20</c>
    //  	            <c>21</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>30</c>
    //  	            <c>31</c>
    //  	        </b>
    //  	    </a>
    //  	    <a>
    //  	        <b>
    //  	            <c>100</c>
    //  	            <c>101</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>110</c>
    //  	            <c>111</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>120</c>
    //  	            <c>121</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>130</c>
    //  	            <c>131</c>
    //  	        </b>
    //  	    </a>
    //  	    <a>
    //  	        <b>
    //  	            <c>200</c>
    //  	            <c>201</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>210</c>
    //  	            <c>211</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>220</c>
    //  	            <c>221</c>
    //  	        </b>
    //  	        <b>
    //  	            <c>230</c>
    //  	            <c>231</c>
    //  	        </b>
    //  	    </a>
    //  	</tripleNested>
    // 

    //  Parse the XML, without needing to know the number of children.
    //  That can be discovered with the NumChildrenAt method.

    i = 0;
    int aCount = xml.get_NumChildren();
    while (i < aCount) {
        xml.put_I(i);
        j = 0;
        int bCount = xml.NumChildrenAt("a[i]");
        while (j < bCount) {
            xml.put_J(j);
            k = 0;
            int cCount = xml.NumChildrenAt("a[i]|b[j]");
            while (k < cCount) {
                xml.put_K(k);
                Log.i(TAG, String.valueOf(i) + ", " + String.valueOf(j) + ", " + String.valueOf(k) + ": " + String.valueOf(xml.GetChildIntValue("a[i]|b[j]|c[k]")));
                k = k + 1;
                }

            j = j + 1;
            }

        i = i + 1;
        }

    //  Output:

    //  	0, 0, 0: 0
    //  	0, 0, 1: 1
    //  	0, 1, 0: 10
    //  	0, 1, 1: 11
    //  	0, 2, 0: 20
    //  	0, 2, 1: 21
    //  	0, 3, 0: 30
    //  	0, 3, 1: 31
    //  	1, 0, 0: 100
    //  	1, 0, 1: 101
    //  	1, 1, 0: 110
    //  	1, 1, 1: 111
    //  	1, 2, 0: 120
    //  	1, 2, 1: 121
    //  	1, 3, 0: 130
    //  	1, 3, 1: 131
    //  	2, 0, 0: 200
    //  	2, 0, 1: 201
    //  	2, 1, 0: 210
    //  	2, 1, 1: 211
    //  	2, 2, 0: 220
    //  	2, 2, 1: 221
    //  	2, 3, 0: 230
    //  	2, 3, 1: 231
    // 

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

 

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