Page 1 of 1

PHP XML DOM save issue

Posted: Wed Jan 19, 2011 10:11 pm
by Bel
This issue is so simple that i cannot resolve it!

Simply all i wish to do at this point is take a xml file that was generated by word and duplicate it. At a later date i will manipulate the xml but for now i cannot even open and save the file!
The XML comes out corrupt is the problem and crashes word upon opening.
The saved XML is valid and scanning it i cannot find the issue.

Is there something im missing about php xml dom?

Code: Select all



    //Altering document XML file
    $xmlDoc = new DOMDocument();
    $xmlDoc->load( 'quotation/'.$_SESSION['account'].'/introduction.xml');
    $xmlDoc->preserveWhiteSpace = false;

    $xmlDoc->save('quotation/'.$_SESSION['account'].'/introduction_copy.xml');

Re: PHP XML DOM save issue

Posted: Thu Jan 20, 2011 4:50 am
by cpetercarter
Have you looked at the xml file in a hex editor (which shows the hex value of every byte in the file)? It is possible that Word has added 'left-to-right' markings or some other non-visible markings to the file. In fact, creating an xml document in a word-processor is a bad idea. Use a proper text editor.