Re: modify xml before parse
| From: | Adam Zey | Date: | Wed, 28 Jun 2006 15:10:36 +0000 |
| Subject: | Re: modify xml before parse | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238802@lists.php.net to get a copy of this message | ||
weetat wrote:
Hi Adam, Thank for your input. However search and replace the value such as <![CDATA[ù?¸ü÷ú"<ù?àù?ØZ4ÀÏ]]> to empty string ? Try the code below , no successful. $xmlfile = "/home/gvintranet/datacraft/htdocs/properties/test_cdata.xml"; $xml = file_get_contents($xmlfile); $xml = preg_replace('/<HardwareVersion>[^(\\/HardwareVersion)]<\\/HardwareVersion>/', '<HardwareVersion><\/HardwareVersion>', $xml); fwrite(fopen($xmlfile, 'wb'), $xml); Thanks - weetat Adam Zey wrote:$xml = preg_replace("/<!\\[CDATA\\[.+?\\]\\]>/", "", $xml); (Keep in mind I wrote that regex for RegexCoach and then tried to translate it to PHP, might be some mistakes) Regards, Adam.weetat wrote:Why not:Hi all, I need to read xml file before it was parsed by PHP DOM functions. The xml file have some encrypted value as shown below :$xmlfile = file_get_contents("http://urloffile.com/filename.xml"); I mean, that is what you asked, how to read the xml file... Regards, Adam Zey.<InstanceName><![CDATA[ù?¸ü÷ú"<ù?àù?ØZ4ÀÏ]]></InstanceName>Anybody have any suggestion how to do it ? Thanks. - weetat