03-23-2009, 12:37 PM
|
#3 (permalink)
|
|
The Wanderer
Join Date: Jan 2008
Posts: 13
Thanks: 0
|
I tried it, but I already have a namespace, so why do I need to create a new one?
This is the current code I have:
PHP Code:
$oImport = new DOMDocument; $oImport->formatOutput = true; $oImport->loadXml('<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:p> <w:pPr> <w:jc w:val="center"/> <w:rPr> <w:rFonts w:ascii="Arial" w:hAnsi="Arial"/> <w:color w:val="000000"/> <w:sz w:val="34"/> <w:szCs w:val="34"/> </w:rPr> </w:pPr> <w:r> <w:t xml:space="preserve">Test sponsor</w:t> </w:r> </w:p> </w:document>'); echo "The 'new document' before copying nodes into it:\n"; # echo $oImport->saveXML(); $oImport->createElementNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'w', 'This is the root element!'); $node = $oImport->getElementsByTagName('w:p')->item(0); $oDoc = new DOMDocument; $oDoc->loadXml($this->sDocument);
# echo $bookmark[0]->nodeName; $node = $oDoc->importNode($node, true); // And then append it to the "<root>" node $oDoc->documentElement->appendChild($node); # echo "\nThe 'new document' after copying the nodes into it:\n"; echo $oDoc->saveXML();
But this is the error I get:
Quote:
|
Catchable fatal error: Argument 1 passed to DOMDocument::importNode() must be an instance of DOMNode, null given, called in C:\Program Files\xampp\htdocs\Webstores-Eindproject\test\word2.php on line 22 and defined in C:\Program Files\xampp\htdocs\Webstores-Eindproject\classes\word\class.reader.php on line 128
|
This is line 128
PHP Code:
$node = $oDoc->importNode($node, true);
So it goes wrong on this line
PHP Code:
$oImport->getElementsByTagName('w:p')->item(0);
It's logic it goes wrong with the namespace but I have no idea on how to fix it
Last edited by Ultimatum : 03-23-2009 at 01:08 PM.
|
|
|
|