I m simply wanting to add cdata to an xml node - description. My xml function is below. I have tried using bits of the following function on php.net in my function
<?php
function updateXMLFile($itemName, $description, $pageName, $imageFileName)
{
$imageSrc = "<img src= http://nicolaelvin.com/authoring/phpThumb/phpThumb.php?src=../images/" . $imageFileName . "&w=100 />";
$id = strtolower($id = str_replace( , _ , $itemName));
$directLinkToItem = http://nicolaelvin.com/authoring/ . $pageName . .php# . $id;
$xml = simplexml_load_file( nicolaElvinsPortfolio.xml );
$item = $xml->channel->addChild( item );
$item->addChild( title , $itemName);
$item->addChild( pubDate , date( r ));
$item->addChild( link , $directLinkToItem);
$item->addChild( description );
$cdata->description->createCDATASection( testyfhgjhsgsdjahgs );
$item->appendChild($cdata);
///Format XML to save indented tree rather than one line
$dom = new DOMDocument( 1.0 );
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
//Save XML to file - remove this and following line if save not desired
$dom->save( nicolaElvinsPortfolio.xml );
}
//function from php.net
function sxml_cdata($path, $string)
{
$dom = dom_import_simplexml($path);
$cdata = $dom->ownerDocument->createCDATASection($string);
$dom->appendChild($cdata);
}
?>