Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Ordering Child Elements

May 3, 1999

Consider the following DTD snippet....

	<!ELEMENT CONTACT (NAME EMAIL)>
	<!ELEMENT NAME (#PCDATA)>
	<!ELEMENT EMAIL (#PCDATA)>

In this case, we expect to see XML along the lines of:

        <CONTACT>
        <NAME>Jim Sanger</NAME>
        <EMAIL>sanger@sanger.com</EMAIL>
        </CONTACT>

Alternatively, the following code would be valid:

        <CONTACT>
        <EMAIL>sanger@sanger.com</EMAIL>
        <NAME>Jim Sanger</NAME>
        </CONTACT>

Notice that since we simply listed the children of CONTACT as a space delimited list, we do not specify any order in which the children should appear. Had we used a comma to separate the list, we would be forcing an order. Thus if we redefined our DTD to use:

	<!ELEMENT CONTACT (NAME, EMAIL)>
	<!ELEMENT NAME (#PCDATA)>
	<!ELEMENT EMAIL (#PCDATA)>

Then the following XML would be valid:

        <CONTACT>
        <NAME>Jim Sanger</NAME>
        <EMAIL>sanger@sanger.com</EMAIL>
        </CONTACT>

but the following XML would be invalid because the EMAIL element would not be allowed to precede the NAME element.

        <CONTACT>
        <EMAIL>sanger@sanger.com</EMAIL>
        <NAME>Jim Sanger</NAME>
        </CONTACT>

Defining Elements and their Children
Introduction to XML For Web Developers | Table of Contents
Repeated Elements


Up to => Home / Authoring / Languages / XML / Tutorials / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers