将文件加载到字符串中后尝试 preg_match_all ..
$string= '<![CDATA[This is a song link at www.otherwebsite.com]]>'; // string of data or your xml file...
preg_match_all('/<!\[(CDATA)\[\s*(.*?)\s*\]\]>/',$string,$out);
$current_link = $out[2][0]; // print_r($_out); to see what is in this new array...
$current_link = str_replace("This is a song link at ","",$current_link); // now remove clutter
echo $current_link;
如果您想处理多次出现的 CData....
$var = ' sdf sdf sdf<![CDATA[This is a song link at www.awesome.com]]> sdf sdf sd<![CDATA[This is a song link at www.google.com]]><![CDATA[This is a song link at www.amazon.com]]>';
preg_match_all('/<!\[(CDATA)\[\s*(.*?)\s*\]\]>/',$var,$out);
$array_of_links = $out[2];
foreach($array_of_links as $link){
$current_link = str_replace("This is a song link at ","",$link);
echo $current_link;
echo "<br />";
}