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);
|