Forum


Replies: 6   Views: 3501
Template, saves curropt file.
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by fortech  · 09-06-2011 - 13:58

I'm trying to do a simple variable replace with a template I created only to have it save a corrupt docx file. I've identified the issue.

The XML from my template looks like this:
[b]$[/b]</w:t></w:r><w:r w:rsidR="00C750CD" w:rsidRPr="00725C26"><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="20"/></w:rPr><w:t></w:t></w:r><w:proofErr w:type="spellStart"/><w:r w:rsidR="00C750CD" w:rsidRPr="00725C26"><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="20"/></w:rPr><w:t>[b]TEST[/b]</w:t></w:r><w:proofErr w:type="gramStart"/><w:r w:rsidR="00C750CD" w:rsidRPr="00725C26"><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="20"/></w:rPr><w:t></w:t></w:r><w:proofErr w:type="spellEnd"/><w:proofErr w:type="gramEnd"/><w:r w:rsidR="00C750CD" w:rsidRPr="00725C26"><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="20"/></w:rPr><w:t xml:space="preserve">[b]$[/b]

When it should look like [b]$TEST$[/b]. Word is adding in all this extra xml in the middle of my variables, making them unable to be found. Is there a special way to easily clean the Word xml file? Is there a clean function that can be run on the xml file before replacing the variables? I've tried several approaches at writing one with no success.

I'm using the latest version of Word.

Thanks.