Re: modify xml before parse

From: 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:
weetat wrote:
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 :
    <InstanceName><![CDATA[ù?¸€ü÷Œú"<ù?àù?؀Z4À„Ï]]></InstanceName>
Anybody have any suggestion how to do it ? Thanks. - weetat
$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.
Why not:
$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.

« previous php.general (#238802) next »