Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/29/2000
Times viewed :
303
Developers Guide to XML
This is the developers guide to XML on theTopXMLwebsite. On
these pages, we package XML in a way that you can easily pick up and use in Visual
Basic, ASP, Cold Fusion and Javascript.
XML - what is it?
XML is a hugely complex topic, you can be a guru on an issue and be completely ignorant
of another up and coming area. In this book, we will be restricting our scope of interest
to focussing on XML from the perspective of a Visual Basic (or ASP) developer. There is an
amazng amount of syntax to learn before you can tutor someone else in XML, but for our
needs, we will be focussing on the basics.
XML was born from the shortcomings of SGML [Structured Generalized Markup Language]
which was hugely complex, massively flexible and just plain hard to work with for many
developers. Needless to say, XML has taken off like a rocket because it has all the best
ingredients of SGML without many of the downsides.
So, XML was designed from the ground up to be extensible and to be simple to implement.
As a result, it seems that attempt to be simple and to be flexible have resulted in the
massive adoption of XML in the computing industry.
Unfortunately anything which is so flexible and extensible will be used for a
bewildering array of uses and eventually the number of choices and solutions begin to
overlap and perhaps compete with each other.
But not only that, many of the technologies we are going to use, such as XSL and the
DOM Level 2, are still subject to change.
As the XSL proposal becomes a recommendation, the object model shipped with IE5 may
change and updated objects may be shipped. Should that happen, the methods and properties
may change in the new version and the code in this book may need to be changed
However if you are using a combination of IE5 and the MS object such as "Microsoft
XML 2.0", then you will be able to use these examples.
Learning more about the XML syntax
If you would like to learn about the details of the syntax of XML, please have a look
at our Links section for an appropriate
website.
The X(ML) files
Many XML applications have three basic files.
The .XML file (with the data in it) - which will be indexed and searched by the web
search engines (for example)
Optional file: DTD or Schema file which provides structure for the XML file - this is
the vocabulary which your XMl file uses
Optional file: XSL which provides the "look" of the XML file - this defines
how the
Bear in mind that XML files do not need to have DTD or XSL files, as they are
optional and serve different purposes to the cre XML file.
How is an XML based application structured?
Overall, this is the pattern which is followed:
How do I create XML files using VB?
For VBScript/ASP developers, use the following syntax to create a new XML document
programmatically
<%
Dim xmldoc
Set xmldoc = CreateObject("Microsoft.XMLDOM")
%>
And for VB programmers, you first have to add a reference to your project to the
"Microsoft XML, version 2.0" object (you must have installed IE5). And
then you can use:
Dim xmldoc As DOMDocument
Loading a file synchronously
Private sub click_LoadXMLFile()
Dim xmldoc As DOMDocument
Dim docRoot As IDOMNode
then load an XML document using the load method as follows:
xmldoc.async = false;
xmldoc.load("http://somewhere.com/test.xml");
Set xmldoc = new DOMDocument
xmldoc.load ("resume.xml")
End Sub
How do I programatically manipulate the XML file?
You saw code above which shows our VB application programmatically loading an XML file.
This was using the DOMDocument object. To understand what a DOM (document
object model) is, first lets look at some HTML code for a table.
<TABLE>
<TBODY>
<TR>
<TD>XML and the Internet for Visual Basic 6 </TD>
<TD>Mark Wilson</TD>
</TR>
<TR>
<TD>Another book </TD>
<TD>Someone Else</TD>
</TR>
</TBODY>
</TABLE>
This would show up in the HTML page as:
XML and the Internet for Visual Basic 6
Mark Wilson
Another book
Someone Else
From the programmers DOM perspective, you wont see the table as the user does.
Instead you see it as
and using your VB code, you will move around the different node. It's very sexy!
There are also DOMs for HTML and DHTML, so you can use the same approach to
manipulate your HTML files.
For more information, please see our Links
page, or our Articles page