XML とはどういう 意味ですか? 質問する

XML とはどういう 意味ですか? 質問する

ファイルCDATA内に次のような奇妙なタグがよく見つかります:XML

<![CDATA[some stuff]]>

CDATAこのタグは常に先頭に表示され、その後に何かが続くことに気づきました。

しかし、それが使用される場合もあれば、使用されない場合もあります。これは、some stuffその後に挿入される「データ」であることを示すためだと思います。しかし、どのようなデータでしょうかsome stuff? XML タグに書き込むものはすべて、何らかのデータではないでしょうか?

ベストアンサー1

CDATAを意味するキャラクターデータつまり、これらの文字列の間にあるデータには、 XML マークアップとして解釈できるが、そうすべきではないデータが含まれています。

CDATA とコメントの主な違いは次のとおりです。

これは、1 つの整形式のドキュメントから次の 4 つの XML スニペットが与えられたことを意味します。

<!ENTITY MyParamEntity "Has been expanded">

<!--
Within this comment I can use ]]>
and other reserved characters like <
&, ', and ", but %MyParamEntity; will not be expanded
(if I retrieve the text of this node it will contain
%MyParamEntity; and not "Has been expanded")
and I can't place two dashes next to each other.
-->

<![CDATA[
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.
]]>

<description>An example of escaped CENDs</description>
<!-- This text contains a CEND ]]> -->
<!-- In this first case we put the ]] at the end of the first CDATA block
     and the > in the second CDATA block -->
<data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data>
<!-- In this second case we put a ] at the end of the first CDATA block
     and the ]> in the second CDATA block -->
<alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative>

おすすめ記事