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   
createTextNode

We can add a "name" and "title" node to the new cd node in the same way as the last step.


$newNode =& $cdCollection->documentElement->lastChild;
$newNode->appendChild($cdCollection->createElement("name"));
$newNode->appendChild($cdCollection->createElement("title"));
						

Note that we do not actually populate these nodes with the artist name and album title. This is because textual XML data is not of type Element. It is actually a different category of node altogether, either of type TextNode or CDataSection.

As mentioned earlier, the artist's name of your new album is "W3C". This is textual data that belongs in a TextNode. In DOMIT! this is a node of class DOMIT_TextNode, which is created as such:

$newTextNode =& $cdCollection->createTextNode("W3C");

The new text node is appended to the "name" element in the usual manner:


$newCDNode =& $cdCollection->documentElement->lastChild;
$nameNode =& $newCDNode->firstChild;
$nameNode->appendChild($newTextNode);


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