All About XML Portland OR

OK, so you may have heard about XML, and you may even know what it stands for, but what you need uis a realworld example. During this article I will tell you about a recent project that I worked on, and how XML was useful.

Local Companies

Cascade Custom Software
503-922-0135
1000 SW Broadway
Portland, OR
Advantyx Software LLC
503-246-9299
6501 SW Macadam Ave
Portland, OR
Aravo Solutions
503-224-4049
2627 NW Nicolai St
Portland, OR
Axis Clinical Software Inc
503-292-3022
6443 SW Beaverton Hillsdale Hwy
Portland, OR
ApogeeInvent
403.407.9915
9999 SW Wilshire St. Ste. 100
Portland, OR
Cendix
503.789.2676
501 4th Street, Suite 741
Lake Oswego, OR
Artisan Software Tools Inc
503-245-6200
10220 SW Greenburg Rd
Portland, OR
Vision33
971-255-0162
The Lincoln Center, 10260 SW Greenburg Road, 4th Floor
Portland, OR
Paradigma Software
(503) 574-2776
6107 SW Murray Blvd #151
Beaverton, OR
ClearStar.net
360-892-0687
915 Broadway
Vancouver, WA

provided by: 
Originally published at Internet.com


OK, so you may have heard about XML, and you may even know what it stands for, but what you need uis a realworld example. During this article I will tell you about a recent project that I worked on, and how XML was useful.

I suppose that I should introduce XML before I dive into any examples. XML stands for Extensible Markup Language and, in a way, it's a bit like HTML. But, unlike HTML that has fixed tags such as

and with fixed attributes XML allows you to create your own tags and attributes. In this way you can build a structered data file where the tags and attributes describe that data they contain.

A few weeks ago I was involved in a project where an existing application needed to be upgraded. The existing system worked by gathering a large amount of data, formatting and outputting it to an HTML page.

The problem was that this process took quite a long time, and only produced one HTML page. The idea was to get the program to output the raw data to a structered XML file, and then use a set of XSL files (XML style sheets) to format the data into different HTML pages. And I only had two weeks to do it in!

As you can see, I was having to learn all about XML and XSL and therefore I feel it would be good to share this knowledge.

In my view, without XSL (XSL is basically like a stylesheet, except it has its own syntax) XML is not very practical. XSL allows you to extract the data of a tag and format it however you want.

Say you have an XML document that looks like this: Sam Huggill

This is very simple, but with XSL you can extract the value in-between the and tags and format it. We extract the value of a tag using the tag:

(Notice the closing />. This means that the tag does not need another tag). Easy.

But what happens when we have a more complicated XML document: Sam Huggill sam@vbsquare.com Yourname youremail

For this we will have to set up a loop to write the data from both tags. We loop using the tag:

Attributes can make things a lot easier. For example, our previous XMl document could be changed so that it uses attributes quite easily:

We can read attributes by using the tag and prefixing the attribute name with an @ sign:

Our loop now looks like this:

In XSL, you can encapsulate code in a "template". This acts rather like a function, and can be very useful. Here is a typical template:

You can call a template using the tag.

We can now rework our loop to use a template:

In XSL, you do have variables but you cannot assign them values at runtime, so I suppose it would be more approriate to call them constants. XSL does have one useful function that returns a number which corressponds to the number of times a loop has occurred:    

Anyway, getting back to variables, you declare them like this: myvalue

To get the value of a variable use:

As you have seen both of these technologies show great promise for the web, but how can we use them for VB? Well, instead of the XML file containing numbers, why not contain Visual Basic code? And, instead of outputting to an HTML file, why not output to a Visual Basic class module?

Using XML you can create smart database classes that work on a database schema. For example, take a look at the following XML document:

This shows a simple database structure that you can use to generate VB code from.

Resources for XML

Here are some useful resources that you should check out:

XT - James Clarks implementation of an XML parser (IE5 comes with one but I think that this is better)

XML Zone - The DevX have set up a web site espically for XML

XML on MSDN - If you're using the XML parser that comes with IE5, you better look here

XML at the W3C - The home of XML and all web related technologies. Check here for the latest developments and the XML/XSL specifications.

Oh well, I am afraid that's about all you're going to get. This article has by no means covered all that you need to know, but hopefully it has shown you why these technologies are useful. Take a look at the resources I have listed and download the zip file which contains a sample XML and XSL document. Download the files

Author: Sam Huggill

Read article at Internet.com site

Featured Local Company

Cascade Custom Software

503-922-0135
1000 SW Broadway
Portland, OR

Related Local Events
WOOD TECHNOLOGY CLINIC & SHOW 2010
Dates: 3/9/2010 - 3/11/2010
Location: Oregon Convention Center
Portland, OR
View Details

Party in the Pinot
Dates: 7/25/2009 - 7/25/2009
Location: Oswego Hills Winery
West Linn, OR
View Details