Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

XML For Dummies

XML For Dummies

by Ed Tittel, Frank Boumphrey, Natanya Pitts

See All Formats & Editions

XML lets developers capture, manipulate and exchange virtually any kind of document or data, without loss of integrity. Because XML lets you create common formats for sharing information between devices and platforms—such as mobile phones, Web browsers and company data stores—many experts have begun calling it the “lingua franca,” or


XML lets developers capture, manipulate and exchange virtually any kind of document or data, without loss of integrity. Because XML lets you create common formats for sharing information between devices and platforms—such as mobile phones, Web browsers and company data stores—many experts have begun calling it the “lingua franca,” or universal language of the Digital Age. Developers, especially developers for the Web and intranets, can’t afford to be XML illiterate. But that powerful markup language has a lot of rules and can be a bit tricky to master. And that’s where this book comes in.

XML For Dummies offers you a fast, fun, and easy way to become XML literate. With a minimum of technobabble and tons of sample applications and case studies, the authors get you on track with XML and all its special features. You’ll:

  • Make the most of XML’s extensible characteristics
  • Combine XML and XHTML
  • Get the hang of DTDs, XML Schema, XLink, and XPath
  • Design XML applications to support graphics, complex linking, document navigation, multimedia, and more
  • Use XML with style sheets and XSL

From the abc’s of markup languages to XML Web services, XML For Dummies covers all the bases. Designed to give you the practical experience you need to put XML to work right away, it offer hands-on, step-by-step coverage of:

  • Planning and defining XML documents
  • Creating custom DTDs
  • Using XML schema
  • Using and delivering XML content
  • Linking languages, including the XML linking language, path language, and pointer language
  • Creating documents with authoring tools
  • Using XML parser engines and conversion tools
  • XML Web services

As an added bonus, XML For Dummies comes with a CD-ROM containing a goldmine of powerful XML development tools, including:

  • Example markup from the book
  • XML Spy, Epic Editor, and IBM XML Schema Quality Checker
  • AElfred, XML4J, Amaya and other freeware and open source products

With XML, the dream of total data connectivity and exchange is at last a reality. Don’t get left behind. Get XML For Dummies and join the XML revolution.

Product Details

Publication date:
For Dummies Series
Edition description:
Older Edition
Product dimensions:
7.46(w) x 9.20(h) x 0.95(d)

Read an Excerpt

Chapter 4: Understanding XML Document Structure

In This Chapter
  • Mastering the basics of creating an XML document
  • Exploring techniques for good XML coding
  • Understanding the virtues of completeness
  • Realizing that well-formedness implies more than it says
  • Figuring out when you've got it right

In this chapter, we explore the meaning of the terms valid and well formed in relation to XML documents. Then we demonstrate good XML coding techniques. After you master the concept of good coding, you find out how complete XML delivers good structure overall. This leads to a discussion of what well formed really means in an XML document. After you get all that under your hat, you find out how to tell whether you've coded your XML correctly.

Mastering the Basics: Pieces and Parts

Writing XML code is easy. All you need is a text editor -- you can even make up your own tag names! Before you begin creating XML documents, however, we need to talk about a few things.

You must understand a couple of buzzwords in order to create correctly formatted XML documents: valid and well formed. These two terms are often bantered about whenever techie types discuss XML. In this section, you uncover what these two terms mean -- without the usual jargon.

A well-formed road is a good road

All XML documents must be well formed -- end of story! A well-formed XML document follows a few specific rules to make the document easy for a computer program to read. See the section entitled "Making XML Well-Formed" later in this chapter for the complete scoop on creating well-formed XML.

Seeking validation

Although all XML documents must be well formed -- or else they aren't XML -- not all XML documents have to be valid. This doesn't mean you don't want valid XML documents. Validity just adds another layer of structure that can be helpful when you want to use or reuse a document. After all, a structured document is better than one that can contain any old set of tags in any old order.

A valid XML document adheres to a Document Type Definition (DTD). To answer the next inevitable question, a DTD defines a set of rules that specify which tags can legally appear in your document. A DTD also spells out how those tags can appear: It indicates their order and which tags can appear within other tags. Simply put, a DTD tells you what your tags can and cannot do; therefore, a DTD defines the rules that XML markup in a document must follow.

DTDs are not necessary, or required, for every instance of XML. However, they do give your XML documents an extra layer of organizational structure that can make your life easier. DTDs also help developers share expectations about document structures. If you're interested in reading more about DTDs, please see Chapter 5.

Now that you know what to look out for, open your text editor so we can get started.

Preambles and Definitions Start the Game

A well-formed XML document always begins with a declaration that announces that the document is written using XML 1.0, so speak up and declare yourself!

Declare yourself!

A declaration for an XML document is simple. It occurs in the first line of your XML document. Currently, a declaration must point to XML version 1.0 -- after all, it's the only version out there. An XML declaration looks like this:

[image missing]

To be honest, you don't have to include an XML declaration in every XML document. If you don't point to a particular version, XML 1.0 is the default. However, we suggest that you get in the declaration habit for all XML documents because when version 2.0 comes out, XML declarations might be required.

You can write fancier declarations for XML documents if you want. For more XML declaration details, see Chapter 2.

Document it

If you decide to use a DTD to add organization and structure to an XML document, you must declare that DTD. (Remember that a DTD defines the rules of the game for your XML document. To find out more about creating and using DTDs, consult Chapter 5.) To declare a DTD in an XML document, you need just one simple line:

Document-Name SYSTEM "Document-Name.dtd">

There you have it -- one line of code that says it all for the related DTD!

Good Bodies Make for Good Reading

Have you ever picked up an instruction manual and wished you hadn't? You know the ones we mean -- chock full of grammatical errors, poor syntax, and just plain lousy sentence structure. After hours of struggling to finish assembling a do-it-yourself bookcase, you wonder why the author took the time to write a manual at all. You might be tempted -- and rightfully so -- to make the same value judgment about XML code. If the code lacks structure from a human-readable standpoint, perhaps the document containing that code is of poor quality.

This section explains how to write good -- that is, well-formed -- XML code to keep others from saying bad things about your work later!

The root of the matter

In HTML, you begin every HTML document with . The . . . tag pair is the root element for an HTML document. With XML, you create elements just like you use predefined HTML tags. The only difference with XML is that you get to choose the name for your root element. For example...

Meet the Author

Ed Tittel is a full-time writer and trainer who has more than 110 computer books to his credit. Natanya Pitts and Frank Boumphrey have both written several books on HTML and XML.

Customer Reviews

Average Review:

Post to your social network


Most Helpful Customer Reviews

See all customer reviews