I made a form in php so that we could electronically fill out a form rather than faxing back and forth, and make it more legible.

The issue I'm having is populating the final page, I was handed a form created in Word 2007, which I converted to a Word 2003 XML since I figured it would be easier to populate the fields.

I can open the XML in the web browser, and I have yet to echo my php session variables into it. The form doesn't show, just the tree does.

Hence my issue is that I have this form in XML, but Word doesn't supply you with an XSLT. So there is no stylesheet, where there must be something somewhere, since Word can open it fine.

Just wondering if someone has had this issue, or might know of a way around it.

Or if there is another way to make this easier, I wouldn't object to the either.

The catch is that the form is from another company, and they are very specific about how they want it to look, so it can't really be changed in any way.

2 answers


I'm not familiar with 2003 XML but are you setting the content-type headers? If you send the document and don't say it's a word document, it will appear as a plain xml file. I know that you could send an HTML table and it will automatically open in Excel if you set the content-type to be application/vnd.ms-excel. Not sure which will be the one for word 2003.

You could also try searching for OpenXML. I believe there are libraries in PHP that let you manipulate this MS new document standard.

Answered almost 7 years ago by weemonster
  • <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?mso-application progid="Word.Document"?> <w:wordDocument xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve"><w:ignoreSubtree w:val="http://schemas.microsoft.com/office/word/2003/wordml/sp2"/> D'arc Whitman almost 7 years ago
  • Those are the first few lines of the XML D'arc Whitman almost 7 years ago
  • Try outputting the whole file to the browser and adding the content type like this: header("Content-Type: application/msword"); . If it works like the Excel case I mentioned, you should receive a prompt for opening it in MS Word or saving it to disk. weemonster almost 7 years ago

The XML document you are using is doubtlessly full of tags from a Microsoft-defined namespace that have no meaning outside of Word and are not going to magically turn into valid HTML in any browser.

Answered almost 7 years ago by Nathan Duran
  • Is there another format that would work better for this. I know I can turn it into a PDF, and possible add in the fields that need to be filled out. But I am not sure if there is a way to populate those fields server side. D'arc Whitman almost 7 years ago
  • Why don't you actually build an HTML form? Nathan Duran almost 7 years ago