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
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Create Attributes in an XML Document with Visual Basic

Download Chilkat XML ActiveX

Source Code Listing

' This example requires Chilkat XML v3.0.0
' Modify the crisp.xml document by relocating some information
' as attributes instead of child nodes.
Private Sub Command3_Click()
    Label3.Caption = "Working..."
    Label3.Refresh
    
    Dim xml As New ChilkatXml
    Dim outXml As New ChilkatXml
    Dim node As ChilkatXml
    Dim langNode As ChilkatXml

    ' Load the input document.
    xml.LoadXmlFile ("crisp.xml")

    ' Iterate over the "DOC" nodes by calling FirstChild
    ' followed by NextSibling2 repeatedly until it returns false.
    Set node = xml.FirstChild()
    Do While Not (node Is Nothing)
      
        Set langNode = node.FindChild("Language")
        If Not (langNode Is Nothing) Then
      
          ' Add the language information as an attribute of the "DOC" node.
          node.AddAttribute "language", langNode.Content

          ' Remove the "Language" node from the document because the
          ' information is now stored as an attribute of the parent.
          langNode.RemoveFromTree
        
        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 (node.NextSibling2() = 0) Then
            Set node = Nothing
        End If
    Loop

    xml.SaveXml "CreateAttributes.xml"
    
    Label3.Caption = "Done."

End Sub

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

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