Sample code for 30+ languages & platforms
AutoIt

DNS Query NS Records

See more DNS Examples

Shows how to perform a DNS query to retrieve NS records.

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

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oDns = ObjCreate("Chilkat.Dns")

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.EmitCompact = False

$bSuccess = $oDns.Query("NS","x.com",$oJson)
If ($bSuccess = False) Then
    ConsoleWrite($oDns.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($oJson.Emit() & @CRLF)

; Sample response.
; Parsing code below..

; {
;   "answer": {
;     "ns": [
;       {
;         "name": "x.com",
;         "ttl": 86400,
;         "domain": "alexia.ns.cloudflare.com"
;       },
;       {
;         "name": "x.com",
;         "ttl": 86400,
;         "domain": "tosana.ns.cloudflare.com"
;       }
;     ]
;   }
; }

; Use this online tool to generate parsing code from sample JSON: 
; Generate Parsing Code from JSON

Local $sName
Local $iTtl
Local $sDomain

Local $i = 0
Local $iCount_i = $oJson.SizeOfArray("answer.ns")
While $i < $iCount_i
    $oJson.I = $i
    $sName = $oJson.StringOf("answer.ns[i].name")
    $iTtl = $oJson.IntOf("answer.ns[i].ttl")
    $sDomain = $oJson.StringOf("answer.ns[i].domain")
    $i = $i + 1
Wend