Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Unicode
Upload
XML
XMP
Zip Compression

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


VB Strings
VB Byte Array

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

Find Matching XML Records in Visual Basic

Download Chilkat XML ActiveX

Source Code Listing

' Iterate over the ArticleTitles beginning with "M"
' using FindNextRecord.   Move these records from
' the input XML document to the output XML document.
Private Sub Command6_Click()
    Label6.Caption = "Working..."
    Label6.Refresh
    
    Dim xmlDoc As New ChilkatXml
    Dim outXml As New ChilkatXml
    Dim rec1 As ChilkatXml
    Dim rec2 As ChilkatXml
    
    outXml.Tag = "MRecords"

    ' Load the input document.
    xmlDoc.LoadXmlFile "crisp.xml"

    ' Find the first article beginning with M
    Set rec1 = xmlDoc.FirstChild()
    ' If rec1 matches, it returns itself.
    Set rec1 = rec1.FindNextRecord("ArticleTitle", "M*")
    Do While Not (rec1 Is Nothing)
    
        ' Continue the search with the next sibling.
        Set rec2 = rec1.NextSibling()

        ' This has the effect of removing the subtree rooted
        ' at rec from xmlDoc, and adding it to outXml
        outXml.AddChildTree rec1

        If Not (rec2 Is Nothing) Then
          Set rec1 = rec2.FindNextRecord("ArticleTitle", "M*")
        Else
          Set rec1 = Nothing
        End If
          
    Loop

    ' Save the output document.
    outXml.SaveXml "MRecords.xml"

    ' The original document is now without articles
    ' beginning with M
    xmlDoc.SaveXml "MissingMRecords.xml"

    Label6.Caption = "Done."

End Sub

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

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