When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
Technology Jobs
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs

The 4 Guys Present: ASPFAQs.com

Jump to a FAQ
Enter FAQ #:
..or see our 10 Most Viewed FAQs.

4GuysFromRolla.com : ASP FAQS : XML


Question:

What is XML?


[Print this FAQ]

Answer: This FAQ was written by Doug Setzer and Scott Mitchell

XML stands for eXtensible Markup Language. Simply said, XML is a method of representing data. You can think of XML as a database. XML is stored in a document in a hierarchical fashion, with there being a root node and child nodes underneath of it.

Some Examples
A good example of XML document is a simple HTML page:

<html>
<head>
<title>My Document Title</title>
</head>
<body>
My document body.
</body>
</html>

At a glance, you can see that we are working with a "html" document.
There is header data defined. More specifically, we have given a "title" to our document. The body of the document is clearly denoted, as well.

Taking that same idea, say we have a set of cars. Each car has data about
it:

- Make
- Model
- Trim Level
- Type of Car
- # of Doors

One design of XML would be:

<cars>
<car>
<make>Chrysler</make>
<model>300M</model>
<trim>Special</trim>
<type_of_car>Sports Sedan</type_of_car>
<doors>4</doors>
<car>
<car>
<make>Chevrolet</make>
<model>Corvette</model>
<trim>Z06</trim>
<type_of_car>Sports</type_of_car>
<doors>2</doors>
<car>
</cars>

As you can easily see, we have my 2 favorite cars. A Chrysler 300M
Special and a Chevrolet Corvette.

XML Syntax Specifics
When working with XML, there are some important syntactical issues to keep in mind. First, XML is case-sensitive, meaning that the tag:

<car>

and

<Car>

Are considered different tags. Furthermore, XML documents must be properly nested. That is, each tag must have a start and end tag, and, when declaring a tag within another tag, it is vital that the inner tag's closing tag appears before the outer tag's closing tag. For example, the following is an example of illegal XML syntax due to improper tag nesting:

<car>
<color>Red
<make>Chevy
</car></make>

Since the make tag is declared within the <car> tag, the closing tag (</make>) must appear within the <car> tag. Another problem is that the <color> tag does not have a matching close tag.

Due to these syntactic rules, all valid HTML Web pages are not necessarily valid XML documents. This is because HTML is case-insensitive and allows for improper tag nesting. There is, however, a variant of HTML called XHTML that requires conforming HTML documents to be syntactically correct XML documents.

Using XML
So, that's all fine and dandy, you say. But, how do you *use* XML? There are a hundred and one answers to that. First, you could use it as a database instead of Access, Sql Server or Oracle. Second, you could take that data and send it to a car buying service. Third, you could build that XML from your database to separate the front-end display of your site from the data retrieval.

The benefit of XML is that it is text. This means that it can easily be shared among disparate platforms, and across firewalls. In English, this means that XML is an excellent way to transfer data from one Web server to another. For example, if you want to syndicate content from your Web site to other Web sites, such as the AP and Reuters Web sites do, you can provide your content in an XML file that other Web sites can programmatically access and incorporate into their Web pages.

Learning More About XML
In addition to reading the other XML FAQs, you can learn more about XML by checking out the following articles:

* Getting Started with XML
* Server-side XML in ASP
* XML: SuperGlue for the Web
* XML Basics
* Learning XML (a book)


FAQ posted by Scott Mitchell at 2/17/2003 1:12:58 PM to the XML category. This FAQ has been viewed 50,061 times.

Do you have a FAQ you'd like to suggest? Suggestions? Comments? If so, send it in! Also, if you'd like to be a FAQ Admin (creating/editing FAQs), let me know! If you are looking for other FAQs, be sure to check out the 4Guys FAQ and Commonly Asked Messageboard Questions!

Most Viewed FAQs:

1.) How can I format numbers and date/times using ASP.NET? For example, I want to format a number as a currency. (761643 views)
2.) I am using Access and getting a 80004005 error (or a [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)' error) when trying to open a connection! How can I fix this problem? (207777 views)
3.) How can I convert a Recordset into an array? Also, how can I convert an array into a Recordset? (202549 views)
4.) How can I quickly sort a VBScript array? (196039 views)
5.) How can I find out if a record already exists in a database? If it doesn't, I want to add it. (156019 views)
6.) How do I display data on a web page using arrays instead of Do...While...MoveNext...???... (152331 views)
7.) When I get a list of all files in a directory via the FileSystemObject, they aren't ordered in any reasonable way. How can I sort the files by name? Or by size? Or by date created? Or... (140381 views)
8.) For session variables to work, must the Web visitor have cookies enabled? (110162 views)
9.) Can I send emails without using CDONTS? (107083 views)
10.) How can I take the result of a SELECT...MULTIPLE or a group of same-named checkboxes and turn it into a query? That is, if the user selects 3 answers, how can I construct a query that looks for all 3? (106308 views)
Last computed at 9/17/2007 3:22:00 AM

Software Developer / Programmer - Distributed Systems (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume


ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article