DOMIT! v 0.1 Tutorial
<<    index    >>
1    2    3    4    5    6    7    8    9    10    11    12    13    14    15   
16    17    18    19    20    21    22    23    24    25    26   
createCDATASection

One might assume from the previous example that the title of the album, "Disco <XML>" can be added in the same way as the name of the artist. However, a quick glance at the text of the proposed node shows a problem with this approach:

<title>Disco <XML></title>

The angle brackets in the title are indistinguishable from standard XML angle brackets! Although this will not cause a problem when creating a node, an XML parser would trip up on any string that did not notify it in some way that "<XML>" was textual data, not an XML Element!

The DOM specification provides a way around this issue - the CDATASection node. An XML parser will interpret anything within a CDATASection node as textual data. It looks like this:

<title><![CDATA[Disco <XML>]]</title>

A DOMIT_CDATASection node is created like this:

$titleNode =& $cdCollection->createCDATASection("Disco <XML>");

And we can add the new title node in the usual way:

$newCDNode ->childNodes[1]->appendChild($titleNode);

Note that you cannot nest CDATASection nodes.


Documentation generated by ClassyDoc, using the DOMIT! and SAXY parsers.
Please visit Engage Interactive to download free copies.