Forum Moderators: coopster

Message Too Old, No Replies

PHP search replace

search and reaplce

         

gowni

7:04 am on Jul 22, 2003 (gmt 0)

10+ Year Member



Hi
I need help with search and replace in .doc(ms word) files
when search and replace is performed using php on ms word(.doc) files,the files get corrupted the resulting files does not open.
anyone any ideas on how to do it?

bilalak

7:58 am on Jul 22, 2003 (gmt 0)

10+ Year Member



Try to open the file in binary and then parse the xml structure.
Doc files have a CRC check up. The best way is to parse the xml stucture then write the doc file again.
A long procedure

gowni

8:46 am on Jul 22, 2003 (gmt 0)

10+ Year Member



Hi
i have not worked on xml before
i tried to workout with binary form but i could not get it.
do you have any examples?
thanks

bilalak

9:19 am on Jul 22, 2003 (gmt 0)

10+ Year Member



have a look at doc2xml on fresh meat

vincevincevince

5:07 pm on Jul 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if they are saved as RTF you'll be better off - and word reads / writes RTF with pretty much zero loss

gowni

3:57 am on Jul 23, 2003 (gmt 0)

10+ Year Member



yes i have to save as rtf only but after search and replace is perfomed or
save as rtf first then search and replace is also fine.

vincevincevince

7:50 am on Jul 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes, if you save FIRST as rtf... then you can use str_replace or preg_replace on that as much as you like - and you won't corrupt it :-) (i've been doing this quite a bit, no corrupting)