i have this script:
$dom=new DOMDocument();
$xml='../assets/local.xml';
$dom->load($xml);
$cdata=$dom->createCDATASection('95.55.4.2');
foreach ($dom->getElementsByTagName('connection') as $item) {
$item->getElementsByTagName('host')->item(0)->appendChild($cdata);
}
$dom->save($xml);
And my xml is:
<connection>
<host>localhost</host>
</connection>
and i need to change "localhost" to "95.55.4.2" with CData. I try this scrip but he wrong... that is the result:
<connection>
<host>95.55.4.2localhost</host>
</connection>
Any can help me please
Thanks!!