In searching how to wright cdata tags into my xml document using simpleXML i came across this example and when i try and use it Dreamweaver shows that lines 4-7 are wrong i try and run the code anyway and i get this error
syntax error, unexpected T_VARIABLE on line 4
<?php
class SimpleXMLExtended extends SimpleXMLElement{
public function addCData($cdata_text){
$node= dom_import_simplexml($this);
$no = $node->ownerDocument;
$node->appendChild($no->createCDATASection($cdata_text));
}
}
$xml_doc = new SimpleXMLExtended('save.xml',NULL,TRUE);
$email = $xml_doc->addChild('email');
$email->addAttribute('id',$id);
$email->from = NULL;
$email->from->addCData($from);
$xml_doc->asXML('save.xml');
?>