Friday 1 December 2017

What does in XML mean?

itemprop="text">

I often find this strange
CDATA tag in XML
files:




            stuff]]>


I have
observed that this CDATA tag always comes at the beginning, and
then followed by some stuff.



But sometimes it is
used, sometimes it is not. I assume it is to mark that some
stuff
is the "data" that will be inserted after that. But what kind of data
is some stuff? Isn't anything I write in XML tags some sort of
data?



Answer




href="http://www.w3.org/TR/REC-xml/#sec-cdata-sect" rel="noreferrer">CDATA
stands for rel="noreferrer">Character Data and it means that the data in between these
strings includes data that could be interpreted as XML markup, but
should not be.




The key differences
between CDATA and comments
are:





This means given
these three snippets of XML from one well-formed
document:



            MyParamEntity "Has been
expanded">


/>






/>

Within this
Character Data block I can
use double dashes as much as I want (along with
<, &, ', and ")
*and* %MyParamEntity; will be expanded to the
text
"Has been expanded" ... however, I can't use
the CEND sequence.
If I need to use CEND I must escape one of the
brackets or the greater-than
sign using concatenated CDATA
sections.

]]>


/>

An example of
escaped CENDs



]]]]>]]>


CEND
]]]>]]>



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...