Skip to Content
Learning XML
book

Learning XML

by Erik T. Ray
January 2001
Beginner to intermediate
368 pages
9h 10m
English
O'Reilly Media, Inc.
Content preview from Learning XML

2.2. Elements: The Building Blocks of XML

Elements are parts of a document. You can separate a document into parts so they can be rendered differently, or used by a search engine. Elements can be containers, with a mixture of text and other elements. This element contains only text:

<flooby>This is text contained inside an element</flooby>

and this element contains both text and elements:

<outer>this is text<inner>more
text</inner>still more text</outer>

Some elements are empty, and contribute information by their position and attributes. There is an empty element inside this example:

<outer>an element can be empty: <nuttin/></outer>

Figure 2.7 shows the syntax for a container element. It begins with a start tag (1) consisting of an angle bracket (<) followed by a name (2). The start tag may contain some attributes (3) separated by whitespace, and it ends with a closing angle bracket (>). An attribute defines a property of the element and consists of a name (4) joined by an equals sign (=) to a value in quotes (5). An element can have any number of attributes, but no two attributes can have the same name. Following the start tag is the element's content (6), which in turn is followed by an end tag (7). The end tag consists of an opening angle bracket, a slash, the element's name, and a closing bracket. The end tag has no attributes, and the element name must match the start tag's name exactly.

Figure 2.7. Container element syntax

As shown in Figure 2.8, an empty element ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning XML, 2nd Edition

Learning XML, 2nd Edition

Erik T. Ray
Beginning XML, 4th Edition

Beginning XML, 4th Edition

Jeff Rafter, Danny Ayers, Jon Duckett, Eric van der Vlist, Joe Fawcett, Linda McKinnon, David Hunter, Andrew Watt
XML Schema

XML Schema

Eric van der Vlist
Java and XML, 3rd Edition

Java and XML, 3rd Edition

Brett McLaughlin, Justin Edelson

Publisher Resources

ISBN: 0596000464Catalog PageErrata