Web Templates
Web Templates  
Photoshop Layouts  
Flash Templates  
Templates Resource - Web Templates
   
 
  Sign UpPassword
Templates Resource Services Support Specials Members View Cart
 
  Photoshop Tutorials
  HTML Tutorials
  ASP Tutorials
  CSS Tutorials
  Javascript Tutorials
  PHP Tutorials
  XML Tutorials
  Flash Tutorials
  Fireworks Tutorials
  3D Studio Max Tutorials
  Cinema 4d Tutorials
  Graphics
  Website Tools
  Web Templates
  About Templates Resource
  Affiliates Program
  TR Support
  Webmaster Resources
 Columbia Tech Support

WebDesignHelper.co.uk


 

XML Tutorials

Commenting and CDATA

Intermediate

 

This article will teach you about commenting and learning how to write text which you want to go unparsed in XML.

Commenting

Sometimes, your code can get long and complicated, and you may forget what part of your code does. Commeting is done in a programming language if you want to write notes in your file to remember what a part of your file does. It is also a good idea to comment because it lets other people who are viewing your code know what you are doing. You can insert comments anywhere inside your code, and XML will completely ignore the text you have inside the comment. To write a comment in XML, you have to write:

<!-- This part of the script gives information -->

Anything inside the <!-- --> tag will be ignored by the XML language. It can be as long as you'd like, spanning as many lines as you'd like. Get in the habit of using comments; they always come back to help you later on.

Having Unparsed Text

So what if you want to write a bit of HTML or other programming language code directly inside the XML file? Well, that's a problem because everything's new to XML. However, the clever people who made XML devised an ingenious way, called CDATA, to place code in XML. Just like commenting, everything inside these tags is sent unparsed by XML. However, insted of it being ignored by the parser, it is just copied directly on to the HTML page. For example, if you wanted to display a picture and write the code for it in HTML inside an XML pag, you could write:

<![CDATA[
<img src="main.jpg" height="23" width="34" alt="Main" />
]]>

To have XML not parse a specific blob of data, you start by writing <![CDATA[ , place the text you don't want parsed in the middle, and end it by the ]]> . You can write any code you want in any language, and you don't have to follow any XML rules inside the CDATA. The one rule to follow is that you cannot have another ]]> inside the CDATA, so no nested CDATAs are allowed.

 

This tutorial is provided to you by Spoono

More Tutorials
 

XML Tutorials

Commenting and CDATA
This article will teach you about commenting and learning how to write text which you want to go unparsed in XML.

Beginner

Intro to XML
This article will give a brief introduction to XML.

Beginner

RSS - Really Simple Syndication
RSS, or Really Simple Syndication is an XML-based format that allows links, news posts, and other lists to be displayed in an organized manner.

Intermediate

XML Rules
Learn the simple rules of XML.

Beginner

XML Stylesheets
This article will introduce you to the XSL stylesheet language and how it can be used to display XML as HTML in a browser.

Intermediate

More Tutorials

Web Template Preview 92310001

Web Templates ID:

92310001

User Level:

Intermediate web template


Web Template Preview 92310201

Web Templates ID:

92310201

User Level:

Intermediate web template


Web Template Preview 92310301

Web Templates ID:

92310301

User Level:

Intermediate web template


Web Template Preview 92310401

Web Templates ID:

92310401

User Level:

Intermediate web template


Templates Resource FAQ Terms of Use Site Map Link To Us

© Copyright 2003-2008 Templates Resource