Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

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

More Examples...
Email Object
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA


VB Strings
VB Byte Array

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

 

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

Need a specific example? Send a request to support@chilkatsoft.com

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