Edit bookmark value in document.xml of .docx documents
Posted: Wed Jan 06, 2010 10:22 am
Hi all
first of all sorry for my bad English...
Microsoft's .docx files are created based on Open XML Format, so if you change the name of the document from test.docx to test.zip and open with lets say winrar you will see a bunch of XML's, and the content of the document will be inside a folder "word" in a document called document.xml. The basic structure is something like that:
My question is: How can i create a function that receive the bookmark value (in this case "BNAME") as parameter and change the correspondent value (in this case "BVALUE") to something that i want...
My knowledge with PHP is not very good, and with xml is also not as good as i want and would be a great help by anyone who can help!!!
Thank you all very much in advance
first of all sorry for my bad English...
Microsoft's .docx files are created based on Open XML Format, so if you change the name of the document from test.docx to test.zip and open with lets say winrar you will see a bunch of XML's, and the content of the document will be inside a folder "word" in a document called document.xml. The basic structure is something like that:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
<w:body>
<w:p w:rsidR="00300719" w:rsidRDefault="007C7B0D">
<w:proofErr w:type="gramStart"/>
<w:r>
<w:t xml:space="preserve">Hi </w:t>
</w:r>
<w:r w:rsidR="00591674">
<w:t xml:space="preserve"> </w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="BNAME"/>
<w:proofErr w:type="spellStart"/>
<w:r w:rsidR="006D5D43">
<w:t>BVALUE</w:t>
</w:r>
<w:bookmarkEnd w:id="0"/>
<w:proofErr w:type="spellEnd"/>
<w:proofErr w:type="gramEnd"/>
</w:p>
<w:sectPr w:rsidR="007C7B0D" w:rsidRPr="00C315C6" w:rsidSect="00300719">
<w:pgSz w:w="11906" w:h="16838"/>
<w:pgMar w:top="1417" w:right="1701" w:bottom="1417" w:left="1701" w:header="708" w:footer="708" w:gutter="0"/>
<w:cols w:space="708"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>
My knowledge with PHP is not very good, and with xml is also not as good as i want and would be a great help by anyone who can help!!!
Thank you all very much in advance