0

![enter image description here]It reads whole document text but i want the code which reads specific text from word document. for eg. Consider there are few form fields say Name: and the text box i want to read only the value from that text box and not as Name:abc only abc should be returned. any help will be appreciated.

<?php 
    $filename = "doc.docx";
    $zip = new ZipArchive();
    if( $zip->open( $filename, ZIPARCHIVE::CHECKCONS ) !== TRUE ) 
    { 
        echo 'failed to open template'; 
        exit; 
    }
    $file = 'word/document.xml';
    $data = $zip->getFromName($file);
    $doc = new DOMDocument();
    $doc->loadXML( $data );
    echo $data;
?>
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Ravindra
  • 101
  • 2
  • 1
    I think you should provide a stripped down XML containing only the elements/parts you are interested in, then someone may be able to provide an XQuery and/or PHP code example how to do it. – Günter Zöchbauer Dec 18 '13 at 11:54
  • hi, i have a form designed in MsWord and from that form i have to extract the values using php and store them in mysql database.i dont have an xml format. – Ravindra Dec 18 '13 at 12:05
  • As I understand your question you want to extract data from 'word/document.xml' which is an XML file. You can open that file in any text editor and strip it down so that only the part relevant to the question remains and then add this part to your question. – Günter Zöchbauer Dec 18 '13 at 12:08
  • i wanted to upload the image of the form but it says u need at least 10 reputation to upload an image . :( – Ravindra Dec 18 '13 at 12:16
  • I dont have an xml file i have a simple word file which has a form fields named name,country and so on user will enter the values in text box besides the name and selects the country where he belongs to and he will upload that document on our server we have to read the values he has entered. – Ravindra Dec 18 '13 at 12:18
  • `Name: Ravindra` – Ravindra Dec 18 '13 at 12:30
  • i have saved it as xml and the above code it has generated its just a one text field vale – Ravindra Dec 18 '13 at 12:31

0 Answers0