Re: modify xml before parse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux