You are on page 1of 14

New to XML

Document options

What is XML?
What can I do with XML? Documen Print
Platform-independent configuration and deployment instructions t options this
Does XML lend itself to application development? requiring page
Transforming XML data (XSLT) JavaScrip
Can I use XML with my favorite programming language? t are not
Are there existing XML vocabularies and applications? displayed
How is XML related to Web services and SOA?
What does the future hold for XML? E-mail
What is the best way for me to improve my XML skills? this
Summary page

New site feature


Check out our
new article design
and features. Tell
Need help getting started with XML? The XML zone on developerWorks us what you think.
contains articles, tutorials, and tips to help developers with XML-based
development. For users trying to find their way in a new topic, all of that More resources
information can be overwhelming. This page provides an overview for readers
who want to learn about XML, but don't know where to start. This page helps World Wide
you get organized and on your way -- whether you want to understand what Web
XML is all about, explore Ajax, mashups or RSS, or prepare for XML Consortium
certification.
OASIS

What is XML? W3C XML


XML, or EXtensible Markup Language, is a platform-independent way to overview
represent data. Simply put, XML enables you to create data that can read by
any application on any platform. You can even edit and create it by hand, W3C XSL
because it is based on the same tag-based technology that underlies HTML. overview

An example W3C DOM


overview
For example, suppose you want to use XML to store information about a
transaction. This transaction originates on your salesman's iBook, so you'll SAX
want to store it there. But it will then be sent to the data application on your documentation
Windows server, and ultimately archived on your mainframe, so it needs to be
very flexible. XML enables you to create something like that shown in Listing W3C XML
1. Schema
overview
Listing 1. XML example W3C
HTML/XHTM
<?xml L
version="1.0
"?>
<transaction W3C SVG
ID="THX1138" overview
>
W3C RDF
<salesperson overview
>bluemax</sa
lesperson>
<order>

<product
productNumbe Special offers
r="3263827">

<quantity>1<
/quantity>

<unitprice
currency="st
andard">3000
000</unitpri
ce>

<description More offers


>Medium
Trash
Compactor</d
escription>

</product>
</order>

<return></re
turn>
</transactio
n>

Serialized this way, as text, the information is available in any environment in


which you might need it. Even without a special application, you can see the
content (in bold) and the markup, which describes it.

Learning more

XML is fairly straightforward to use, once you understand its structure. It also
provides several different methods by which you can control the structure, and
even the content, of your data. Once you begin to use XML, you'll also have
questions about the best way to design your XML structures, but it doesn't
have to be a complicated process.

Get started with these resources:

 Introduction to XML
 Validating XML
 The Java XML Validation API
 XML Data Management: Information modeling with XML

The flexibility of XML means that it's useful for so many applications, such as
configuration files, Web services, data storage, and so on.

Back to top

What can I do with XML?


Since its introduction, developers have found numerous uses for XML. Here
are some resources that give you an idea of how you can put XML to work.

Storing data

The most obvious use of XML is to store data. XML provides advantages for
both data-centric information (such as the data you find in a database) and
document-centric information (such as data you store in XML so you can
display it differently in different environments.)

Learn more about XML as a data-centric storage medium in these resources.

 An introduction to XQuery: Debunking XQuery myths and


misunderstandings
 Query DB2 XML data with XQuery
 Develop Java applications for DB2 XML data
 DB2 XML evaluation guide
 Introduction to Xindice

If you're interested in storing XML data, you should know that IBM provides a
no-charge version of the new DB2 9, IBM DB2 Express-C 9. You should also
check out the new DB2 Developer Workbench, which makes it easier to use
XQuery and SQL/XML with DB2 9.

This first tutorial in a three part series shows you how to use XML to
generically store document-centric data, manipulating its presentation later:
 Use Cascading Stylesheets to display XML, Part 1 introduces the use
of CSS to style XML in browsers.
 IBM Notes/Domino 6 provides a great deal of opportunity for
publishing XML data. Check out Publishing XML Data using
Notes/Domino 6 for more information.

Web services

Web services began as a way to pass non-HTML information over HTTP.


They have grown to be the foundation for fields from Ajax, used to add
interactivity to Web sites, to today's Service Oriented Architectures (SOA),
complex message-based applications. XML is integral to the field of Web
services. All of the leading methods of Web services, SOAP, REST, and even
XML-RPC, are based in XML.

To learn how XML is used in the field of Web services, explore these
resources:

 Understanding Web Services specifications, Part 1: SOAP


 Resource-oriented vs. activity-oriented Web services

See the section below on XML and Web services for more information.

Podcasting and other data syndication

One of the most common uses of XML today is in the realm of syndication.
Millions of bloggers use RSS feeds to keep up with the latest information on
their favorite blogs, and commercial interests have begun taking an interest in
podcasting, or distributing audio and video over the internet to devices such as
iPods, which also uses XML.

See what the syndication landscape looks like in these resources:

 Introduction to Syndication, (RSS) Really Simple Syndication


 Podcasting for developers
 Working XML: Expand RSS capabilities with RSS extensions
 Tip: Use Universal Feed Parser to tame RSS

Back to top

Platform-independent configuration and deployment instructions


A common place to find XML is behind the scenes of your favorite
applications and development environments, where it serves as a common
means for creating files of configurations or instructions. Providing
configuration instructions in a human-readable XML file enables users to
control the behavior of applications much more easily than before.

Review these samples of how to use XML in this way:

 Apache Ant 101: Make Java builds a snap


 Enhance Ant with XSL transformations
 Using multiple Struts configuration files

Back to top

Does XML lend itself to application development?


Although the tags you see in Listing 1 are the most common serialization of
XML, it is very common to deal with XML data in the context of an
application. In that case, you will typically use one of several models,
including the following.

The Document Object Model (DOM)

The Document Object Model, or DOM, is an object-based, tree-like way to


view XML data. For example, in Listing 1, the salesperson, order, and return
elements are children of the transaction element, meaning that they are
contained below it in the hierarchy. DOM is the primary way in which most
XML-based applications deal with XML.

Begin to understand DOM with these resources:

 Understanding DOM
 Discover key features of DOM Level 3 Core, Part 1
 Discover key features of DOM Level 3 Core, Part 2

The Simple API for XML (SAX)

DOM is useful when you are trying to manipulate data, because everything
resides in memory. On the other hand, it can be quite a resource hog, because
everything resides in memory.

The Simple API for XML, or SAX, solves the problem of having everything in
memory at one time by analyzing data from the beginning of the document to
the end, and notifying your application of every event, such as "start element"
or "characters". It's more resource friendly than DOM, but you can't
manipulate the data in quite the same way.
Start to understand SAX with these resources:

 Understanding SAX
 Tip: Set up a SAX parser

DOM and SAX are the most common ways of programmatically interacting
with XML, but sometimes you don't need to build an application to manipulate
XML data.

Back to top

Transforming XML data (XSLT)


Sometimes the manipulation you want to do with XML doesn't even require
programming. You can manipulate XML using EXtensible Stylesheet
Language Transformations, or XSLT. XSLT enables you to transform an XML
document into a different XML structure, or even into a non-XML structure.
XSLT is extremely powerful, and very commonly used.

 Hands-on XSL
 Improve your XSLT coding 5 ways
 Working XML: Using XSLT for content management

Back to top

Can I use XML with my favorite programming language?


XML is platform and programming-language independent, so you can use it
with virtually any programming language, as long as the underlying software,
such as a parser, which reads the text file of tags and creates the XML
Document for manipulation, is available. Learn how to work with XML using
various programming languages with these resources:

Java

XML parsing and other capabilities are built directly into Java.

 XML programming in Java technology, Part 1 of a 3 part series


 The Java XML Validation API
 The Java XPath API

PHP
PHP support for XML started out a bit rough; early implementations weren't
quite in synch with the DOM specification. These days, however, the situation
is much better, with more standard-like support.

 Use PHP and XSL to create a DHTML link graph

Perl

Perl was designed to work with text, so sometimes the temptation is to work
on the text directly rather than use XML methods, but the benefits are
definitely there.

 Perl developers: Fill your XML toolbox


 Effective XML processing with DOM and XPath in Perl
 Dare to script tree-based XML with Perl

Python

With Python's ease of use and XML's emphasis on cross-platform availability,


the pair is a match made in heaven.

 Develop Python/XML with 4Suite, Part 1: PyXml, of a five part series.


 Python Web services developer: The power of three: Python, Web
services and XSLT
 XML Matters: The ElementTree API

C++

C++ programmers can also get their hands on XML capabilities.

 Make the most of Xerces-C++, Part 1


 Make the most of Xerces-C++, Part 2
 Serialize XML data

Ruby

The REXML library provides XML support for the Ruby programming
language.

 XML Matters: The REXML library

JavaScript

JavaScript support for XML is very similar to that of Java, at least in the more
basic operations.

 XML in Firefox 1.5, Part 3: JavaScript meets XML in Firefox

Back to top

Are there existing XML vocabularies and applications?


As developers began to use XML for various applications, standard
vocabularies, or XML applications, began to emerge. For example, XHTML is
an XML version of HTML, and podcasting takes place using various flavors of
an XML vocabulary called RSS. The Scalable Vector Graphics (SVG)
language provides a way to define graphic images using XML in a way that
browsers such as Firefox can render them.

Some examples of XML in action are discussed below.

RSS and syndication

Bloggers often provide external feeds that show their most recent posts and
provide links back to the original material. These feeds have turned into big
business, with advertisers taking note, and the distribution of audio and/or
video, or podcasting, becoming the focus of major media companies such as
the broadcast television networks. These feeds are in the form of XML, either
in one of the varieties of RSS, or Atom.

 An introduction to RSS news feeds


 Content feeds with RSS 2.0
 Grab headlines from a remote RSS file
 Podcasting for developers
 Thinking XML: Use the Atom format for syndicating news and more

Scalable Vector Graphics (SVG)

SVG tries to do for graphics what HTML did for desktop publishing, provide a
way to specify graphics using small, simple text instructions. SVG enables you
to create complex graphics that are both small in terms of bandwidth, and
controllable programmatically.

 XML Matters: Program with SVG


 Create vector graphics in the browser with SVG
 Practical business graphing with SVG and XML
 Render dynamic graphs in SVG
 Dynamic SVG features for browsers

XForms

Think of XForms as the next generation of HTML forms, providing a way to


specify the information to be collected in a presentation-independent way. This
enables you to not only add more functionality more easily than before, but
also to easily reuse forms in other mediums, such as cell phones, where the
information is the same, but the presentation might be totally different.

 Get ready for XForms


 SVG and XForms: A primer
 Tip: Create an XForms form that submits a second instance
 Tip: Use XForms to send and receive Web services messages
 The XML Forms Generator
 Introduction to XForms series

More XML in action

You can find XML in a variety of places, such as publishing, encoding


semantic data, and even those voice recognition units you talk to over the
telephone. Here are some more examples:

 Voice enabling XML, a new four-part series


 XML Security: Ensure portable trust with Security Assertion Markup
Language
 Thinking XML: XML Topic Maps by the book
 Thinking XML: Universal Business Language (UBL)
 XML Watch: Support online communities with FOAF
 XML Watch: Finding friends with XML and RDF
 XML Matters: Getting started with the DocBook XML dialect

Back to top

How is XML related to Web services and SOA?


Although you can implement Service Oriented Architectures (SOA) using a
variety of technologies, the most common is to use Web services, and that
means XML. The two most popular means to implement Web services, SOAP
and REST, are both based on XML.

An example

For example, you can make a request to the Google Web service by sending
this SOAP document as a Web request (see Listing 2).

Listing 2. Making a request to the Google Web service by sending a SOAP


document

<?xml
version='1.0
'
encoding='UT
F-8'?>
<SOAP-
ENV:Envelope
xmlns:SOAP-
ENV=

"http://sche
mas.xmlsoap.
org/soap/env
elope/"

xmlns:xsi="h
ttp://www.w3
.org/1999/XM
LSchema-
instance"

xmlns:xsd="h
ttp://www.w3
.org/1999/XM
LSchema">
<SOAP-
ENV:Body>

<ns1:doGoogl
eSearch
xmlns:ns1="u
rn:GoogleSea
rch"

SOAP-
ENV:encoding
Style=

"http://sche
mas.xmlsoap.
org/soap/enc
oding/">
<key
xsi:type="xs
d:string">00
000000000000
000000000000
000000</key>
<q
xsi:type="xs
d:string">de
ath star
trash
compactor</q
>
<start
xsi:type="xs
d:int">0</st
art>

<maxResults
xsi:type="xs
d:int">10</m
axResults>

<filter
xsi:type="xs
d:boolean">t
rue</filter>

<restrict
xsi:type="xs
d:string"></
restrict>

<safeSearch
xsi:type="xs
d:boolean">f
alse</safeSe
arch>
<lr
xsi:type="xs
d:string"></
lr>
<ie
xsi:type="xs
d:string">la
tin1</ie>
<oe
xsi:type="xs
d:string">la
tin1</oe>

</ns1:doGoog
leSearch>
</SOAP-
ENV:Body>
</SOAP-
ENV:Envelope
>
Here you see the SOAP envelope, a standard format the Web service engine
can understand. The contents of this message, in this case the
doGoogleSearch element, is known as the payload, and consists of the
information to be processed by the Web service.

The overall Web services picture

In fact, most of the standards surrounding Web services -- and there are many
-- are essentially XML vocabularies. Web Service Description Language is an
XML file that describes a service, for example.

Get started with XML and Web services with these resources:

 Understanding Web Services specifications, Part 1: SOAP


 Tip: Use a proxy network library for SOAP behind a firewall
 Tip: SOAP 1.2 and the GET request
 Tip: Make SOAP and Web servers cohabit peacefully
 Tip: Passing files to a Web service

The ETTK for Web Services, an alphaworks technology, makes it easy to set
up a Web services environment, complete with server.

You can get more information on XML and Web services on the New to SOA
and Web services page.

Back to top

What does the future hold for XML?


XML is at the heart of many of today's nascent technologies. For example, as
search engines improve and the world moves towards the Semantic Web,
XML is how webmasters can add meaningful information to their pages. Grid
computing and autonomic computing continue to gain ground, and XML
figures prominently in these technologies, as well. Database vendors continue
to look at storing XML more efficiently, and XML Query Language gains
steam.

In the following sections are resources to help you glimpse the future of XML:

RDF, microformats, and other semantic technologies

The semantic Web doesn't require XML, but you'd be hard-pressed to see that
from the way the technology currently looks. Most information is encoded in
some form of XML, whether it is the Resource Description Framework (RDF),
or independent microformats. This is because of XML's nearly universal
readability and understandability.

 Separate data and formatting with microformats


 XML Matters: Lighter than microformats: Picoformats
 Introduction to Jena
 Thinking XML: Semantic anchors for XML
 XML Watch: Tracking provenance of RDF data
 Thinking XML: XML meets semantics, Part 1 of a four part series

Grid and autonomic computing

The world becomes smaller, and computer systems get bigger. Specifically,
researchers, companies, and other organizations begin to see the advantage in
mending their systems together into a single larger system, either to provide
enhanced computing power or to save money by eliminating waste. Because of
its platform independence, XML is perfect for exchanging information
between disparate systems.

 Meet the Experts: Susan Malaika on XML Standards and Grid


Computing
 Policy Management for Autonomic Computing: Solve a business
problem using PMAC

Asynchronous JavaScript with XML (AJAX)

As the Web becomes more functional, in turn users expect more from the
applications they deal with everyday. Asynchronous JavaScript with XML
(AJAX) provides a more seamless experience for the user by requesting
information -- in XML, more often than not -- in the background and replacing
only part of the page, rather than forcing the user to request a whole new Web
page. As a result, the Web has advanced in leaps and bounds in this area in just
the last year or so.

 Build apps using Asynchronous JavaScript with XML (AJAX)


 The Ajax transport method
 User annotations in Ajax

Mashups

As more information becomes available through Web services, more


enterprising developers find more things to do with it. One way much of this
data has been utilized is in the mashup, a rapidly growing type of application
that combines data from multiple sources into a single view.
 Mashups: The new breed of Web app
 Power your mashups with XQuery
 The ultimate mashup -- Web services and the semantic Web, Part 1:
Use and combine Web services

Back to top

What is the best way for me to improve my XML skills?


If you want to improve your XML skills, the best way to do it is to get a
grounding in the essentials, and then simply use it. Start with the resources
listed under What is XML? and move on to those under Does XML lend itself
to application development?. From there, you can move on to any of the other
areas that interest you.

You can also pursue XML Certification through IBM and prepare for it by
reading XML and Related Technologies certification prep, Part 1: Architecture
and the other tutorials in this certification series.

Back to top

Summary
XML provides you with a great deal of functionality and power, but
fortunately it is itself a fairly simple and straightforward technology. Once you
learn the basics -- and that doesn't take long -- you can pick and choose what
you want to learn. If you are a programmer, you can concentrate on
programming and the various APIs. If you're not, you can concentrate on the
various uses that do not involve programming. Either way, you are sure to find
a place for XML in your work in today's world.

Back to top

You might also like