Introduction
|
Except for comments, the parser is used to "scan"
the whole XML file to analyze it. Every tag is then interpreted. As we mentioned
already, the value of each tag can be displayed in a browser between its opening
and its closing tag, and the browser uses different font styles to make a
distinction.
|
When creating some tags and some sections of the file, you may want
the parser to consider those particular tags and sections as regular text. That
is, you may want the parser to treat a certain tag and its value as if it were
regular text even though it is created as an XML file.
To prevent the parser from interpreting a tag regularly but
to treat that tag and its value as regular text, you can create it in a CDATA
section. To do this, create a section that starts with <![CDATA[,
followed by anything you want, and ending with ]]>. The formula used
is:
<![CDATA[ Blah Blah Blah ]]>
Between <![CDATA[ and ]]>, you can
type anything, including one or more normal XML tags. Here is an example:
<?xml version="1.0" encoding="utf-8"?> <!-- In this collection, we will keep each title "as is" --> <videos> <![CDATA[<VdoColl>Collection of Videos</VdoColl>]]> <video> <title>The Distinguished Gentleman</title> <director>Jonathan Lynn</director> <length>112 Minutes</length> <format>DVD</format> <rating>R</rating> </video> <video> <title>Her Alibi</title> <director>Bruce Beresford</director> <length>94 Mins</length> <format>DVD</format> <rating>PG-13</rating> </video> </videos>
You can then use a CDATA section to create a whole XML
section. Here is an example:
<?xml version="1.0" encoding="utf-8"?>
<!-- In this collection, we will keep each title "as is" -->
<videos>
<![CDATA[
<video>
<title>Name of the Video</title>
<director>Name of the director</director>
<length>Natural Number</length>
<format>VHS, DVD, BluRay, or TV recording</format>
<rating>MPAA Rating</rating>
</video>
]]>
<video>
<title>The Distinguished Gentleman</title>
<director>Jonathan Lynn</director>
<length>112</length>
<format>DVD</format>
<rating>R</rating>
</video>
<video>
<title>Her Alibi</title>
<director>Bruce Beresford</director>
<length>94</length>
<format>DVD</format>
<rating>PG-13</rating>
</video>
</videos>
No comments:
Post a Comment