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


Comments

March 29, 1999

Not only will you sometimes want to include tags in your XML document that you want the XML processor to ignore (display as character data), but sometimes you will want to include character data in your document that you want the XML processor to ignore (not display at all). This type of text is called COMMENT text.

You will be familiar with comments from HTML. In HTML, you specified comments using the <!-- and --> syntax. Well, I have some good news. In XML, comments are done in just the same way! So the following would be a valid XML comment:

<!-- Begin the Names -->
<NAME>Jim Nelson</NAME>
<NAME>Jim Sanger</NAME>
<NAME>Les Moore</NAME>
<!-- End the names -->

When using comments in your XML documents, however, you should keep in mind a couple of rules.

First, you should never have "-" or "--" within the text of your comment as it might be confusing to the XML processor.

Second, never place a comment within a tag. Thus, the following code would be poorly-formed XML:

<NAME <!--The name --> >Peter Williams</NAME>

Likewise, never place a comment inside of an entity declaration and never place a comment before the XML declaration that must always be the first line in any XML document.

Comments can be used to comment out tag sets. Thus, in the following case, all the names will be ignored except for Barbara Tropp.

<!-- don't show these 
<NAME>Kieron Drake</NAME>
<NAME>Bob Woodley</NAME>
<NAME>Roger Kaplan</NAME>
-->
<NAME>Barbara Tropp</NAME>

However, if you do comment out blocks of tags, make sure that the remaining XML is well-formed.

Comments cannot be nested, so if you use a comment to block out a bunch of tags, there can be no comments within the block.

CDATA
Introduction to XML For Web Developers | Table of Contents
Processing Instructions


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