Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Loop Over XML Records in Visual Basic

Download Chilkat XML ActiveX

Source Code Listing

' This example requires Chilkat XML v3.0.0
' Iterate over each "DOC" record and copy the
' ArticleTitle to a new XML document
Private Sub Command2_Click()

    Label2.Caption = "Working..."
    Label2.Refresh
    
    Dim xml As ChilkatXml
    Dim outXml As New ChilkatXml

    ' Load the input document.
    Set xml = New ChilkatXml
    xml.LoadXmlFile "crisp.xml"

    ' Create the output XML document in-memory
    outXml.Tag = "article_titles"

    ' Iterate over the "DOC" nodes by calling FirstChild2
    ' followed by NextSibling2 repeatedly until it returns false.
    ' Calling FirstChild2 updates our internal reference to the first child.
    If (xml.FirstChild2() = 0) Then
      Set xml = Nothing
    End If
    
    ' Note: if "xml" is Dim'med as "New ChilkatXml" then this loop will never exit.
    ' Be sure to Dim it without "new"
    Do While Not (xml Is Nothing)
    
        ' FindChild2 updates our internal reference to the found child.
        If (xml.FindChild2("ArticleTitle") = 1) Then
      
            ' NewChild returns the created child, whereas NewChild2 does not.
            outXml.NewChild2 "article", xml.Content
            ' Restore our internal reference back to the parent.
            xml.GetParent2
            
        End If
        
        ' Move to the next sibling. The internal reference within node is updated
        ' to the node's next sibling. If no siblings remain, it returns 0.
        If (xml.NextSibling2() = 0) Then
            Set xml = Nothing
        End If
        
   Loop
   
    outXml.SaveXml "ArticleTitles2.xml"

    Label2.Caption = "Done."
    
End Sub

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