2

I'm having troubles with transforming .docx to html... I'm using PHPDOCX FREE to handle this problem... I have some problems with it and I was able to determine where the problem was.. it's in the next piece of code:

$xmlDOM = new DOMDocument();
$xml = str_replace('</w:wordDocument>', '', $xml);
$xml = preg_replace(
  '/(<w:wordDocument)+(.)*(><w:body>)/', '<w:body>', $xml
 );

escpecially in the 'preg_replace' function... it's making the server so busy... so I can't work anything until I restart the server...

4

1 回答 1

1

Try replacing this :

$xml = preg_replace(
  '/(<w:wordDocument)+(.)*(><w:body>)/', '<w:body>', $xml
 );

By this :

$xml = preg_replace(
  '/<w:wordDocument.*?><w:body>/', '<w:body>', $xml
 );

Or just (if the wordDocument tag is always folowed by body tag) :

$xml = preg_replace(
  '/<w:wordDocument.*?>/', '', $xml
 );

Using parentheses makes php use more mamory. Wich PHP version you got ?

于 2012-08-05T03:09:58.073 回答