SunQuest
 
       XML
  Home arrow XML arrow Page 3 - Using MSXML3.0 with VB 6.0
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Using MSXML3.0 with VB 6.0
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 19
    2006-11-07

    Table of Contents:
  • Using MSXML3.0 with VB 6.0
  • MSXML Document30 Properties and Methods
  • Creating an XML Document using VB 6.0
  • Adding a child node to the student node
  • Manipulating the XML document

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    IBM developerWorks
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    Using MSXML3.0 with VB 6.0 - Creating an XML Document using VB 6.0


    (Page 3 of 5 )

    In this section I will describe the steps you need to take in creating a document such as the one shown in the next paragraph.

    <?xml version="1.0"?><!--Processing Instruction-->
    <wclass> <!--Root of the XML Doc-->
    <!--Next line is a comment-->
    <!--My students who took web programming class with me-->
    <student id="1"><!-- student node-->
    <name>Linda Jones</name> <!-- Child of Student--->
    <legacySkill>Access, VB5.0</legacySkill><!-- Child of Student--->
    </student>
    <student id="2">
    <name>Adam Davidson</name> 
    <legacySkill>Cobol, MainFrame</legacySkill>
    </student>
    <student id="3">
    <name>Charles Boyer</name> 
    <legacySkill>HTML, Photoshop</legacySkill>
    </student>
    <student id="4">
    <name>Charles Mann</name> 
    <legacySkill>Cobol, MainFrame</legacySkill>
    </student>
    </wclass>]
    

    Creating the root, a comment and a child node

    The XML document will be built bit by bit so that the process is easy to understand, especially if the reader is a first-timer. The document above is built line by line starting from the beginning. Every XML document has a processing instruction at the very top of the document. The document must have a root element. The document may or may not have a comment, but the object model has the necessary method to create one. The code listing shown allows you to create an XML document with the root node "wroot," an element "comment" which is a child of the root, and an element "student" which is also a child of the root.

    Private Sub Command1_Click()
    Dim xmldoc As DOMDocument30
    Dim ProcInstr As IXMLDOMProcessingInstruction
    Dim rootElement As IXMLDOMElement
    Dim aElement As IXMLDOMElement
    'Creating DOM Document object
    Set xmldoc = New DOMDocument30
    'this adds the processing instruction
    'the first line in an XML document <?xml version="1.0"?>
    Set ProcInstr = xmldoc.createProcessingInstruction("xml", 
    "version=""1.0""") xmldoc.appendChild ProcInstr 'Create the root element Set rootElement = xmldoc.createElement("wroot") Set xmldoc.documentElement = rootElement 'Creating comment node Set comElement = xmldoc.createComment ("My students who took web
    programming class with me") 'add the comment node after the root rootElement.appendChild comElement 'Create the node student Set aElement = xmldoc.createElement("student") 'add the student node to the root rootElement.appendChild aElement
    'Saving the xml document to c:testWebStudents.xml xmldoc.save "c:testWebStudents.xml" WebBrowser1.Navigate2 ("c:testWebStudents.xml") End Sub

    When this code is executed by clicking the button labeled "Display the XML Document," the displayed form appears as shown, where a web browser control on the form displays the saved XML. We have added the "student" node, but we need to add the attribute to the student node as well as the details for the student whose "id" =1. Many objects were created and they need to be closed out; this is not shown in the code. The Web Browser control's Navigate2() method shows the XML document.

    More XML Articles
    More By Jayaram Krishnaswamy


       · That being said, it is always good to have a few tools to read through the document,...
       · Excellent article, page 5 was exactly what I needed. Wish I had found this earlier...
     

    XML ARTICLES

    - More on Triggers and Styles and Control Temp...
    - Looking at Triggers with Styles and Control ...
    - A Closer Look at Styles and Control Templates
    - Styles and Control Templates
    - Properties and More in XAML
    - Elements and Attributes in XAML
    - XAML in a Nutshell
    - Importing XML Files into Access 2007
    - Using MSXML3.0 with VB 6.0
    - MSXML, concluded
    - MSXML, continued
    - MSXML Tutorial
    - Generating XML Schema Dynamically Using VB.N...
    - XSL Transformations using ASP.NET
    - Applying XSLT to XML Using ASP.NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway