开发者

Read XML data and write to new file with PHP

I may be over thinking this but are there any extra steps I am missing after reading my XML data into a string and before writing开发者_如何学Python it to a local file?

header('Content-type: text/xml');

//MY URL TO A XML PAGE STYLED WITH XML STYLE SHEET
$url = "http://www.mywebsite.com/somexmlfile.xml";

//SAVE CONTENTS OF PAGE IN XML_DATA
$xml_data = file_get_contents($url);


//REMOVE STYLE SHEET INFO
$search2 = '<?xml-stylesheet href="latest_ob.xsl" type="text/xsl"?>';
$xml_data = str_replace( $search2, "", $xml_data);


//WRITE MY DATA TO A BACKUP FILE AND THEN ECHO TO THE SCREEN FOR A FLASH APP CALLING THE INFO

        $myFile = "data_backup.xml";
        $fh = fopen($myFile, 'w') or die("can't open file");
        $stringData = $xml_data;
        fwrite($fh, $stringData);
        fclose($fh);

        echo $xml_data;

The reason I ask this is when I try opening my backup XML file in Dreamweaver it crashes everytime. I was thinking there could be an encoding issue possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜