0
我以爲我正在從我的PHP腳本中正確創建一個XML文檔從一個MySQL查詢,但我沒有得到一個XML文檔作爲回報(沒有PHP錯誤來幫助我),即使MySQL查詢的作品!在PHP解析XML不工作?
<?php
...
$result = $mysqli->query($sql);
if ($result) { //this query works, but no xml document produced as a result
$d = new DOMDocument();
$books = $d->createElement('hey');
$hey->setAttribute('check','The Adventures of Tom Sawyer');
$d->appendChild($books);
$d->appendChild($hey);
$d->appendChild($books);
echo $d->saveXML();
}
?>
'的var_dump($ d)'? – StasGrin
似乎你必須使用這樣的東西:'$ d = $ d-> appendChild($ books);' – StasGrin