我不能使用以下方法创建新的DOMdocument:
$dom = new DOMDocument;输出只是空的。不是像DOMDocument Object( )那样的空对象,而是完全空的。通常,它应该是一个对象,如:
DOMDocument Object
(
[doctype] =>
[implementation] => (object value omitted)
[documentElement] =>
[actualEncoding] =>
[encoding] =>
[xmlEncoding] =>
[standalone] => 1
[xmlStandalone] => 1
[version] => 1.0
[xmlVersion] => 1.0
[strictErrorChecking] => 1
[documentURI] =>
[config] =>
[formatOutput] =>
[validateOnParse] =>
[resolveExternals] =>
[preserveWhiteSpace] => 1
[recover] =>
[substituteEntities] =>
[...]
)我使用的是PHP5.6.7版本,phpinfo()说:
DOM/XML:启用DOM/XML版本: 20031129 libxml版本:2.9.2
服务器/脚本中还有其他PHP代码,所以我可以说PHP正常运行。有什么建议,接下来的步骤应该是找出原因吗?
发布于 2016-01-21 10:20:26
试试这个:
<?php
$dom = new DOMDocument();
var_dump($dom);
?>产出:
object(DOMDocument)#1 (34) { ["doctype"]=> NULL ["implementation"]=> string(22) "(object value omitted)" ["documentElement"]=> NULL ["actualEncoding"]=> NULL ["encoding"]=> NULL ["xmlEncoding"]=> NULL ["standalone"]=> bool(true) ["xmlStandalone"]=> bool(true) ["version"]=> string(3) "1.0" ["xmlVersion"]=> string(3) "1.0" ["strictErrorChecking"]=> bool(true) ["documentURI"]=> NULL ["config"]=> NULL ["formatOutput"]=> bool(false) ["validateOnParse"]=> bool(false) ["resolveExternals"]=> bool(false) ["preserveWhiteSpace"]=> bool(true) ["recover"]=> bool(false) ["substituteEntities"]=> bool(false) ["nodeName"]=> string(9) "#document" ["nodeValue"]=> NULL ["nodeType"]=> int(9) ["parentNode"]=> NULL ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["attributes"]=> NULL ["ownerDocument"]=> NULL ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> NULL ["textContent"]=> string(0) "" }参考:http://php.net/manual/en/class.domdocument.php
https://stackoverflow.com/questions/34920055
复制相似问题