I wonder how can i add cdata in xml child? i got this code:
$errors = array();
if(isset($_POST['newtopic'])){
$topicname = preg_replace('/[^A-Za-z]/', '', $_POST['topicname']);
$textarea = $_POST['textarea'];
$desc = $_POST['desc'];
$startedby = $_POST['startedby'];
$tn = $_POST['topicname'];
if($topicname == ''){
$errors[] = 'You`re topic title is missing!';
}
if($topicname == ''){
$errors[] = 'You`re textarea is missing!';
}
if(count($errors) == 0){
$xml = new SimpleXMLElement('<topic></topic>');
$xml->addChild('textarea', $textarea);
$xml->addChild('desc', $desc);
$xml->addChild('startedby', $startedby);
$xml->addChild('date', $date);
$xml->addChild('topicname', $tn);
$xml->asXML('topics/sitenews/' . $topicname . '.xml');
header('Location: sitenews.php');
die;
}
}
i wanna add the cdata to $textarea part only, i tried already use '<![CDATA['. $textarea .']]>'
but its not working.
Thank you in advance.