how to get xml CDATA content and write in csv format in php?

Help on PHP

$url = ‘[]=4’;
//get file content but not display in browser because xml content some <![CDATA[ CDATA – (Unparsed) Character Data
$test = file_get_contents($url);
//so we replace replace with @#$ and store into $arr array variable.
//we open or create a file.csv file.
$fp = fopen(‘file.csv’, ‘w’);
//we write a data in csv file from xml data.
//if we write with $srch variable then we remove xml tags otherwise write xml tags in csv.
//create array with xml tags.

//replace a string in for loop and write one by one in csv file.
for($i=1,$j=1;$i<count($arr);$i++,$j++) {


// here my logic is not part of our script.

if($j==14) {

fputcsv($fp, $str);


$str[]=”; $j=0;


} fclose($fp);


View original post


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s